Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Onclick() not working on second button

As you can see in the code, there are two onClick() methods. Both appear on the UI. But when I click on the second onClick() method, it doesn't call the method but the first one calls. I am not able to understand why this is happening. Please help.

        <div class="col-sm-12 text-right mrg-top-15">
            <div class="action-btns text-right flex">
                <span class="icon-pending"></span>
                <vh-button [type]="'trash'" (onClick)="navigateToHRA()" class="mrg-lft-10" id="icd-delete"></vh-button>
            </div>
            <button (onClick)="navigateToHRA()" class="btn btn-primary">{{'LookUpButtonText'|translate}}</button>
        </div>
like image 691
Prashant Yadav Avatar asked Jul 17 '26 02:07

Prashant Yadav


1 Answers

You need to use (click) when using Angular's click event.

<button (click)="navigateToHRA()" class="btn btn-primary">{{'LookUpButtonText'|translate}}</button>

The other (onClick) event is most probably the output event emitter of vh-button component/directive.

like image 73
Harun Yilmaz Avatar answered Jul 18 '26 18:07

Harun Yilmaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!