环境:
我已经将ionic-release71.zip导入到现有的Eclipse工作区中。
在feeds.html
<button data-ng-click="clickMe()">Click Me!</button>在controllers.js中的FeedsController范围内
$scope.clickMe = function(){
alert("123");
console.log("I am clicked");
};完整代码:
app.controller('FeedsController', function($rootScope, $scope, feedsService,
$ionicLoading, $timeout) {
$scope.clickMe = function(){
alert("123");
console.log("I am clicked");
};
$scope.loading = $ionicLoading.show({
content: '<i class="ion-loading-c"></i> Loading...',
animation: 'fade-in',
showBackdrop: true,
maxWidth: 200,
showDelay: 0
});
$scope.getFeeds = function() {
$rootScope.feeds = [];
$scope.errorMsg = "";
feedsService().then(function (feeds) {
$rootScope.feeds = feeds;
$scope.$broadcast('scroll.refreshComplete');
$scope.errorMsg = "";
$scope.loading.hide();
},
function(error) {
$scope.errorMsg = "Could Not Load feeds";
$scope.$broadcast('scroll.refreshComplete');
$scope.loading.hide();
});
};
$scope.getFeeds();
});添加了上面提到的html和js代码。
单击按钮时,clickMe方法会被触发两次。结果,警报会被提示两次并进行记录。
试图通过谷歌搜索和堆叠溢出问题来找出原因。但没能确定是什么导致了这一切..。
发布于 2015-10-07 11:33:51
我下载了示例应用程序并将其加载到运行MFPF7.1的Eclipse中,在指定的地方添加了代码片段,将应用程序部署到服务器上,并从MobileFirst控制台预览公共web资源(在Chrome平稳版,最新版)。
点击“点击我!”按钮,结果是1次警报和1次console.log。
无法繁殖..。
编辑:这只在Android中复制,但也在Mobile模拟器之外(指IBM提供的工具之外)。
https://stackoverflow.com/questions/32988820
复制相似问题