gpt4 book ai didi

javascript - 切换切换时发出警报

转载 作者:行者123 更新时间:2023-12-03 06:26:44 24 4
gpt4 key购买 nike

我想在开关打开和关闭时显示警报,但发现这很困难。我按照本教程进行操作,但我的无法正常工作

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内部,它应该在外部:

.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 };
}])

关于javascript - 切换切换时发出警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38621006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com