Only first ng-click work well

Hi folks,

I use Ionic, v1.0.0-beta.13 for my hybrid app. I’ve noticed a potential bug with ng-click.

My html file

<ion-view title="{{name}}">
  <ion-content has-header="true" padding="true">
    <img ng-src="{{image}}"></img>
    <label class="item item-input">
        <span class="input-label">Name: </span>
        <input type="text" ng-model="name" placeholder="Name">
    <button class="button button-clear button-energized button-medium icon-left ion-ios7-trash" ng-click="delete()">Delete</button>
    <button class="button button-clear button-energized button-medium icon-left ion-ios7-checkmark" ng-click="update()">Update</button>

If I click on the Delete button, the delete() function execute. Good !
If I click on the Update button, the delete() function execute too. Bad !

If I swap the 2 button tags in the html file, the behavior is the opposite.

In summary, the first declared ng-click is always fired even I click on the second button !

Does anyone has the same issue ? has solved it ?

Thank you for your answer.

I’ve pasted your code into a codepen and made the delete/update functions log to the console. I do not see any issues. Maybe compare your controller code to this and see if there are any differences?


ok the issue is that I’ve had a <label> tag before the two <button> and the <label> tag was not properly closed.

The next round of beer is for me :blush:

It happens. Glad you found the problem. :smile: