用于Ionic ng-click的Mobilefirst Starter应用程序两次点火

时间:2015-10-07 09:36:48

标签: javascript angularjs ionic-framework ibm-mobilefirst

环境:

  1. Eclipse 4.4.2,
  2. IBM MobileFirst Platform Foundation 7.1,
  3. StarterApplication_ionic-release71.zip,
  4. angular-route.js [AngularJS v1.2.12示例应用程序的一部分]和
  5. ionic.bundle.js [Ionic,v1.0.0-beta.1样本申请部分]
  6. 我已将StarterApplication_ionic-release71.zip导入现有的Eclipse工作区。

    feeds.html

    <button data-ng-click="clickMe()">Click Me!</button>
    

    FeedsController

    范围内的 controllers.js
    $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方法将被触发两次。这导致警报被提示两次并记录。

    试图在谷歌搜索和stackoverflow问题的帮助下找出原因。但未能确定可能导致这种情况的原因......

1 个答案:

答案 0 :(得分:0)

我下载了示例应用程序并将其加载到运行MFPF 7.1的Eclipse中 添加了指定的代码段,将应用程序部署到服务器并从MobileFirst控制台预览了常用Web资源(在Chrome stable中,最新版本)。

点击“点击我!”按钮,结果是1个警报和1个console.log 无法重现...

编辑:这仅在Android中重现,但也在移动浏览器模拟器之外(意味着在IBM MFP提供的工具之外)。

相关问题