NG-单击在离子应用程序中不起作用

ng-click not working in ionic application

本文关键字:应用程序 不起作用 单击 NG-      更新时间:2023-09-26

这是我演示Ionic Application的简单代码。

<body ng-app="starter" ng-controller="catego">
  <ion-pane >
  <ion-header-bar class="bar bar-positive">        
    <button class="button icon ion-navicon"></button>
    <h1 class="title">Hardware Shop</h1>    
    <button class="button button-clear  icon ion-plus-circled" ng-click="popover.show($event)"></button>         
  </ion-header-bar>
  <div class="bar bar-subheader item-input-inset">
    <label class="item-input-wrapper">
      <i class="icon ion-search"></i>
      <input type="text" placeholder="Search item" ng-model="searchitem"/>
      <button class="button button-clear" ng-click="clear()">NOTWORKING</button>
    </label>
  </div>
  <ion-content class="has-subheader" style="padding:5px !important;">
    <ion-refresher pulling-text="Refreshing..." on-refresh="dorefresh()"></ion-refresher>
      <div class="list" >
        <div ng-repeat="element in data | filter : searchitem| orderBy : 'category'">
          <div class="item item-divider">{{ element.category }}</div>
          <ion-list can-swipe="true">
            <ion-item class=""  href="#" ng-repeat="innerelement in element.companies | filter : searchitem | orderBy : 'toString()' track by $index">
          ---   {{innerelement}}&nbsp;<br/>
            <ion-option-button class="button-positive icon ion-edit"></ion-option-button>
            </ion-item>
          </ion-list>
        </div>
      </div>
   </ion-content>
</ion-pane>
</body>

我的副标题中显示"不工作"的按钮不起作用。我已确保控制台中没有错误,并且所有其他方法都可以正常工作。我错过了什么吗?

任何帮助都非常感谢。

您必须

<button>移动到<label>之外,如下代码所示:

   <div class="bar bar-subheader item-input-inset">
      <label class="item-input-wrapper">
        <i class="icon ion-search"></i>
        <input type="text" placeholder="Search item" ng-model="searchitem" />
      </label>
      <button class="button button-clear" ng-click="clear()">NOTWORKING</button>
    </div>

我发现这个更好,这在我的应用程序上运行良好,在 iOS 上也很好

$scope.$on('$stateChangeSuccess', function() {  
       $('*[ng-click]').each(function() {
            $(this).attr("ng-click");
            $(this).attr("on-touch", $(this).attr("ng-click"));
        });
});