简体   繁体   中英

How can i call a function in Angular in a reactive form

I have a form element in my reactive form like below

 <form [formGroup] = "form" (ngSubmit)="handleClick()">

which works fine when i hit the submit bttn, but i have another bttn on the form from which i want to call a different function. I searched and could not find something that works. i tried something like this

 <button  ng-click=”newClick()” type=”button” class="btn survey-reset-btn">Get Info</button>

or

<button (click)=”newClick($event)” type=”button”>Button</button>

but that creates me an error and complains about the () around click.

sow how can i have bttn on my form which dont call the same function ?

Might be the issue of quote symbol. Replace with " .

<button (click)="newClick($event)" type="button">Button</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM