I’m tryng to changing value of toggle checkbox onfly but toggle check dont work and stay always checked.
This is my HTML:
<li class="item item-toggle"> JOBBER
<label class="toggle toggle-assertive">
<input type="checkbox" ng-model="profilo.job" ng-checked="profilo.job">
<div class="track">
<div class="handle"></div>
</div>
</label>
</li>
<li class="item item-toggle"> SPEEDER
<label class="toggle toggle-assertive">
<input type="checkbox" ng-model="profilo.speed" ng-checked="profilo.speed">
<div class="track">
<div class="handle"></div>
</div>
</label>
</li>
and this is the controller:
.controller('loadProfilo', function($scope, $http, $ionicLoading, $localstorage) {
var username = $localstorage.get('name');
var user_id = $localstorage.get('user_id');
$scope.$watch('profilo.job', function(newValue, oldValue) {
console.log('being watched ldValue:', oldValue, 'newValue:', newValue);
if (newValue!=undefined && oldValue!=undefined){$http.post('http://www.digitalxp.it/appwork/include/upJob.asp?id='+user_id+'&JOB='+newValue).success(function(){}).error(function(){alert("Errore di comunicazione!")})}
})
$scope.$watch('profilo.speed', function(newValue, oldValue) {
console.log('being watched oldValue:', oldValue, 'newValue:', newValue);
if (newValue!=undefined && oldValue!=undefined){$http.post('http://www.digitalxp.it/appwork/include/upSped.asp?id='+user_id+'&SPED='+newValue).success(function(){}).error(function(){alert("Errore di comunicazione!")})}
})
$http.post('http://www.digitalxp.it/appwork/include/profilo.asp?username='+username+'&id='+user_id).success(function(data){$scope.profilo = data;$scope.nome = username;}).error(function(){alert("Errore di comunicazione!")});
})
The value on changing is successfull updated on DB, but when I come back to the page the toggle are always checked!