我想在切換開關處於關閉狀態時顯示警報,但發現它很困難。 我跟着這個教程,但我的不工作,因爲它應該切換切換時的警報
http://codepen.io/rossmartin/pen/iwuvC
JS
.controller('shops',['$scope','$http','$timeout',function($scope,$http,$timeout){
$http.get('http://localhost/site/templates/shop.php').success(function(data){
$scope.shops=data ;
$scope.pushNotificationChange = function() {
$timeout(function() {
alert('Push Notification Change: '+ $scope.pushNotification.checked);
}, 0);
};
$scope.pushNotification = { checked: true };
});
}])
HTML
<ion-view align-title="center">
<ion-content overflow-scroll="false" has-bouncing="true" class=padding>
<ion-list>
<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>
<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>
</ion-list>
</ion-content overflow-scroll="false" has-bouncing="true">
</ion-view>
如何使這項工作任何幫助嗎?
爲什麼所有的代碼被包裝'$ http.get'成功裏面,應該是外面$ http callback –
@PankajParkar,謝謝你的提示。 假設有兩個或更多的切換開關,默認情況下一個是自動打開,另一個打開時我如何使第一個關閉 – neiza