我有嵌套的切換按鈕,默認情況下它是關閉的,當它將值保存到localstorage時。當一個人打開了我想做的事就是和你試圖打開其他上,第一個應該被自動關閉,而在當另一個打開時自動關閉切換按鈕
.controller('shops',['$scope','$http','$timeout',function($scope,$http,$timeout){
$http.get('http://localhost/moves/templates/shopping.php').success(function(data){
$scope.shops=data ;
});
$scope.pushNotification = {};
$scope.pushNotification.text = "Sample"
$scope.pushNotification.checked = false;
$scope.pushNotificationChange = function(item) {
console.log('Push Notification Change', $scope.pushNotification.checked);
if($scope.pushNotification.checked){
localStorage.setItem("shop_id",($scope.item.shop_id));
}else{
localStorage.removeItem("shop_id");
}
};
//$scope.pushNotification = { checked: false };
}])
HTML其他輪流
<div ng-controller="shops" ng-repeat="item in shops">
<ion-item class="item-thumbnail-left item-text-wrap">
<img src="img/index/fashion.png" alt="photo" width="32" height="32" />
<h2>{{item.shop_name}} </h2>
<p>{{item.biz_location}}</p>
<input type="hidden" value="{{item.shop_id}}">
<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>
</ion-item>
</div>
只有一個複選框嗎? –
@AaronSaunders,他們或兩個,可以更多 – user6579134