简体   繁体   English

我如何以反应形式在Angular中调用函数

[英]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. 当我点击submit bttn时,它可以正常工作,但是我要从中调用另一个函数的表单上还有另一个bttn。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何重置 Angular Reactive Form - How can I reset Angular Reactive Form 如何在 angular 反应式表单构建器中调用异步验证器 function 模糊? - How call async validator function on blur in angular reactive form builder? 如何使用Observable初始化Reactive Angular2表单? - How can I initialize a Reactive Angular2 form using an Observable? 如何清除我的 Angular 反应形式? - How can I clear my Angular reactive form? 如何在 Angular 中以反应形式修补图像字段? - How can I patch an image field in a reactive form in Angular? 如何使用反应式表单将表单绑定到 Angular 6 中的模型? - How can I bind a form to a model in Angular 6 using reactive forms? 如何使用从回调函数获得的值以角度设置反应形式控件的值? - How to set value in a reactive form control in angular, using the value obtained from the call back function? Angular Reactive Form:如何为单个表单组件动态调用服务 - Angular Reactive Form : How to call services dynamically for a single form component 编辑时,如何只发送角度2+反应形式的编辑/更改过的字段? - How can I only send edited/changed fields in angular 2+ reactive form when I edit? 在 Angular Reactive Form Array 上使用 RemoveAt(i) 之前如何设置值? - How I can set value before using RemoveAt(i) on Angular Reactive Form Array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM