0

I have tag with ng-click in another tag with ng-click. when i click on the internal tag, its start the two function instead of only internal function. example:

<div ng-click="gotoChat()" >



            <i class="icon" ><button ng-click="Close()" class="button button-assertive">סגור בקשה</button></i>


        </div>

When I click on the button tag, its start gotoChat() and Close() instead of only Close(). How can I fix it?

Ron
  • 399
  • 2
  • 6
  • 22

1 Answers1

0

Couple of Things:

1) You are using Ionic2/Angular2 so you should use (click) event and ion-button (for RC release)

<div (click)="gotoChat()">
  <i class="icon"><button ion-button (click)="Close($event)" class="button button-assertive">Name</button>
</div>

2) What you are looking for is $event.stopPropagation(). Call it on your nested event to keep the event from bubbling up. So, like this:

    Close($event) {
      $event.stopPropagation();
      // handle event
    }

Make sure to pass the $event object to the function you wish to call stopPropagation() on

Pat Murray
  • 4,125
  • 7
  • 28
  • 33
  • why not use ng-click? when I using (click) its give error. its possible to do this with ng-click? – Ron Oct 11 '16 at 08:32
  • okay, so you tagged this question with both ionic 1 and ionic 2. They are completely different. I answered your question for Ionic 2 but I am assuming you are using Ionic 1? If that is the case go ahead and use ng-click but the 2nd part of my answer still applies: http://stackoverflow.com/questions/20300866/angularjs-ng-click-stoppropagation – Pat Murray Oct 11 '16 at 19:08