A
A
Alex Art2019-05-13 10:06:35
Angular
Alex Art, 2019-05-13 10:06:35

How to not call parent (click) in angular cli?

Good day! There is a list of elements, when clicking on each element, its detailed description is revealed using (click)="showElement()". But in the list of elements there is a button, when clicked, I would like to perform another action without triggering showElement. Is it possible to do this? Example

<li (click)="showElement()">
<h2>Название элемента</h2>
<button class="btn_buy btn_buy_filtered" (click)="toCart()">
    <i class="fa fa-shopping-cart"></i> В корзину
</button>
</li>

That is, is it possible to not call the showElement method when clicking on the button? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-05-13
@WebmasterW3S

try

<button class="btn_buy btn_buy_filtered" (click)="toCart(); $event.stopPropagation()">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question