我正在使用离子和angularjs的应用程序,这是我想实现的,当切换开关是它应该设置localstorage为true,当它已关闭,应删除本地存储。保存到localstorage切换和删除localstorage如果它的假
.controller('shops',['$scope','$http','$timeout',function($scope,$http,$timeout) {
$http.get('http://localhost/work/templates/source.php').success(function(data){
$scope.shops=data;
});
$scope.pushNotificationChange = function(item) {
$timeout(function() {
if ($scope.pushNotification = { checked: true }) {
alert("false");
}
//alert('Push Notification Change: '+ $scope.pushNotification.checked);
localStorage.setItem("shop_id",($scope.item.shop_id));
}, 0);
};
}]);
HTML
<div align="right">
<label class="toggle toggle-balanced">
<input type="checkbox"
ng-model="pushNotification.checked"
ng-change="pushNotificationChange()">
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>
,什么是错误?你期望的行为是什么? – CozyAzure
为什么使用'if($ scope.pushNotification = {checked:true})'而不是'if($ scope.pushNotification.checked)'? – Lex