Hi all, I’ve searched and searched and for the life of me can’t figure out how to programmatically change the value of an ion-toggle.
My toggle starts as on. When someone slides it to off, I popup a confirmation. If they cancel the confirmation, I want to reset the toggle back to on but nothing happens (the console prints out “Clicked Cancel” correctly:
<ion-toggle ng-model="twitterConnection" ng-change="twitterConnectionChange()">Twitter</ion-toggle>
$scope.twitterConnectionChange = function() {
$ionicPopup.confirm({
title: 'Are you sure?',
template: 'Are you sure you want to disconnect this account?'
}).then(function(res) {
if(res) {
delete $window.localStorage.twitterToken;
delete $rootScope.user.twitterID;
}
else {
console.log("Clicked No");
$timeout(function () { $scope.twitterConnection = true; });
}
});
};
Here’s a codepen: http://codepen.io/Shiftlemac/pen/pjZRbP
Thanks!