Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-click not working in ionic application

Here is my simple code for a demo 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>

The button in my subheader which says NOTWORKING is not working. I have made sure that there are no errors in the console and all other methods are working fine. Is there something I am missing?

Any help is highly appreciated.

like image 268
Samarth Agarwal Avatar asked Oct 27 '25 11:10

Samarth Agarwal


1 Answers

You have to move the <button> outside the <label> as in the code below:

   <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>
like image 69
beaver Avatar answered Oct 30 '25 00:10

beaver