I'm having difficulties when a checkbox is toggled. By default the checkbox is checked because a value from local storage is set to yes. when the checkbox is toggled the local storage value changes to no and should pop up. But with my script even when the value is set to no, the alert keeps popping up
HTML
<li class="item item-toggle">
Following
<label class="toggle toggle-balanced">
<input type="checkbox" ng-model="set_following" ng-checked="following == 'yes'" ng-change="following()">
<div class="track">
<div class="handle"></div>
</div>
</label>
</li>
JS
$scope.following=function(){
$scope.push_following= localStorage.getItem('push_following')
if ($scope.push_following=='yes') {
localStorage.setItem("push_following",'no');
var confirmPopup = $ionicPopup.confirm({
title: 'Following Notifications',
template: 'Sure you want to stop following User?',
cancelText: 'No',
okText: 'Yes'
});
confirmPopup.then(function(res) {
if(res) {
event.preventDefault();
$http.post("http://localhost/myapp/scripts/follow.php",
{'email':$scope.email}).success(function(data){
}).error(function(error){
//console.error(error);
});
} else {
localStorage.setItem("push_following",'yes');
}
})
}
}