ng-click不适用于离子应用

时间:2016-01-18 17:32:20

标签: javascript html angularjs cordova ionic-framework

这是我的演示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>

我的副标题中的按钮表示NOTWORKING不起作用。我确保控制台中没有错误,所有其他方法都正常工作。有什么我想念的吗?

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:5)

您必须将<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>

答案 1 :(得分:0)

我发现这更好了,这在我的应用程序上工作正常,在Ios上的好姿态

<img src="empty.gif" alt=""
onload="this.src='http://example.com/getImage.php?id=123&rnd='+new Date().getTime()" />