angularjs - Ionic Toggle returning wrong value -


i made simple test ionic toggle alert return false when true , true when false. ideas?

http://codepen.io/anon/pen/jtkcf   $scope.pushnotificationchange = function() {     alert('push notification change: '+ $scope.pushnotification.checked); }; 

your code fine happens tedious timing issue. the official example here suffers same issue yours if @ console log outputs.

here codepen made works using $timeout solves issue.

$scope.pushnotificationchange = function() {     $timeout(function() {         alert('push notification change: '+ $scope.pushnotification.checked);     }, 0); }; 

/edit

here working approach made after seeing tassekatt's comment.

$scope.$watch('pushnotification.checked', function(newvalue, oldvalue) {   console.log('push notification change: ' + newvalue); }); 

you can avoid needing ng-change using alternative approach.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -