我们如何重置控件的验证状态模板驱动角度 2 的形式?
我知道可以通过设置控件所绑定的模型值来重置控件。但是验证状态(原始、肮脏等)又如何呢?
我尝试过这样的事情:
<form (ngSubmit)="onSubmit(playlistForm)" #playlistForm="ngForm">
// Some code here...
</form>
在控制器中,
onSubmit(playlistForm: any) {
// ...
playlistForm.form.reset();
}
但在上面似乎实际上重定向到''
我收到以下错误:
EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: ''
那么我该如何做我想做的事呢?
这两者都对我有用:
playlistForm.reset();
playlistForm.resetForm(); // I think this is the one to use
Angular 文档仅具有 ResetForm()https://angular.io/docs/ts/latest/api/forms/index/NgForm-directive.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)