按钮ng-click在离子

时间:2017-06-01 07:05:49

标签: angularjs ionic-framework

ng-click在离子按钮中不起作用,它在控制台中说如下

  

VM67 index.html:1未捕获的ReferenceError:未定义zPLysearch()

我一直试图解决这个问题2个小时我没有运气。 这是我的代码,

<div class="col-90" >
  <button ng-click="zPLysearch()" class="button button-delete">zPLY search</button>
</div> 

但使用如下所示的相同功能它工作正常

<div class="homecard wired" ng-show="show2" ng-click="zPLYsearch()">
</div>

这是我的完整HTML代码

<ion-view title="zPLY Conf Tool"> 
  <ion-content padding="true" class="content_background">
      <div class=" homecard wired" ng-show="show2" ng-click="zPLYsearch()">
     </div>
      <div class="col-90" >
      <button ng-click="zPLysearch()" class="button button-delete">zPLY search</button>
    </div> 
  </ion-content>
</ion-view>

控制器代码:

angular.module('wiredzplydetailscontroller', [])
  .controller('wiredzplydetailsCtrl', function($scope,$rootScope,$http,$ionicModal,$ionicPlatform, $ionicLoading,$ionicPopup, $timeout, $location) {

$scope.zPLYsearch=function(){ 

}


});

2 个答案:

答案 0 :(得分:1)

你也可以像这样使用按钮点击按钮..

<div class="col-90" > <button ng-click="zPLysearch()" class="button button-delete">zPLY search</button> </div>

答案 1 :(得分:0)

function zPLysearch()
{
  console.log("test");
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div class="col-90" >
  <button onclick="zPLysearch()" class="button button-delete">zPLY search</button>
  
</div>
</body>
</html>