为什么ng-click无法正常工作?

时间:2016-05-05 16:49:25

标签: angularjs ionic-framework

我有这段代码:

  <script src="js/app.js"></script>
  </head>
  <body ng-app="starter" ng-controller="HomeController">

    <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic Blank Starter</h1>
      </ion-header-bar>
      <ion-content>
        <h1>Hello In APP</h1>
        <button type="button" name="button" ng-click="buyAdFree()">Kaufen</button>
      </ion-content>
    </ion-pane>
  </body>
</html>

但是当我点击按钮时没有任何反应。 ng-click不能正常工作。我的错是什么? 这是我的控制者:

app.controller("HomeController", ["$scope", function($scope) {

  $scope.buyAdFree = function() {

    if((window.device && device.platform == "iOS") && window.storekit) {
        storekit.purchase("full_version");
    }

    if((window.device && device.platform == "iOS") && window.storekit) {
        storekit.restore();
    }

    if ((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
      inappbilling.init(function(resultInit) {
          inappbilling.getPurchases(function(result) {
              console.log("PURCHASE RESPONSE -> " + JSON.stringify(result));
            },
            function(errorPurchases) {
              console.log("PURCHASE ERROR -> " + errorPurchases);
            });
        },
        function(errorInit) {
          console.log("INITIALIZATION ERROR -> " + errorInit);
        }, {
          showLog: true
        }, ["full_version"]);
    }
  }
}]);

0 个答案:

没有答案