Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49076

Ionic: $scope for toggle issues

$
0
0

@lovellholiday wrote:

I am currently construct a ionic app that I want to integrate toggle with. when a toggle is clicked, I want my app to send information over through a Bluetooth connection to another device. This is the code I have so far for the toggle controls:

[Controller $scope code]
.controller('MainCtrl', function ($scope) {

$scope.$watch('Auto', function() {
	console.log('Auto Mode Changed');
	if($scope.Auto) {
		console.log('Auto mode activated!');
		app.automode();
	}
	else {
		app.autostop();
		console.log('Auto mode deactivated!');
	}
});
$scope.$watch('Note', function() {
	console.log('Notifications Mode Changed');
	if($scope.Note) {
		app.notemode();
		console.log('Notifications mode activated!');
	}
	else {
                   app.notestop();
		console.log('Notifications mode deactivated!');
	}
});

});
[/code]

That code is supposed to interact with these, defined in the index.html file of my program:

<ion-item class="item item-toggle">
				AutoMode
				<label class="toggle toggle-calm">
					<input type="checkbox" ng-model="Auto">
						<div class="track">
							<div class="handle">
							</div>
						</div>
				</label>
			</ion-item>
			<ion-item class="item item-toggle">
				Notification Mode
				<label class="toggle toggle-assertive">
					<input type="checkbox" ng-model="Note">
						<div class="track">
							<div class="handle">
							</div>
						</div>
				</label>
			</ion-item>

however, when I try to use them, nothing works. the toggles move, but the work that's supposed to go behind them does nothing. I'm guessing that something in my controller code is wrong, but since i'm really new to this, I don't quite get what.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49076

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>