Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

表单重置未生效? #114

Closed
Feng-JY opened this issue Aug 21, 2017 · 7 comments · Fixed by #257
Closed

表单重置未生效? #114

Feng-JY opened this issue Aug 21, 2017 · 7 comments · Fixed by #257

Comments

@Feng-JY
Copy link

Feng-JY commented Aug 21, 2017

I'm submitting a...


[X] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Support request => Please do not submit support request here

Current behavior

表单重置问题,form.reset()后表单dirty仍为true。使用input未出现该情况
image

@vthinkxie
Copy link
Member

bug confirm, thanks.

@vthinkxie
Copy link
Member

related angular/angular#9700

@qwei-1874
Copy link

private resetForm(forms:NgForm[]) {
forms.forEach((form: NgForm) => {
if (form.dirty) {
for (let l in form.controls) {
form.controls[l].markAsPristine();
form.controls[l].markAsUntouched();
}
}
})
}
u can use similar function to do your work

@htmlcss23
Copy link

Can't bind to 'formGroup' since it isn't a known property of 'form'. ("


<form nz-form [ERROR ->][formGroup]="validateForm" class="login-form" (ngSubmit)="_submitForm()">
<div nz-for"): ng:///AuthModule/LoginPageComponent.html@20:26
No provider for ControlContainer ("


[ERROR ->]<form nz-form [formGroup]="validateForm" class="login-form" (ngSubmit)="_submitForm()">
"): ng:///AuthModule/LoginPageComponent.html@20:12
No provider for NgControl (" <div nz-form-control [nzValidateStatus]="validateForm.controls.userName">
[ERROR ->]<nz-input formControlName="userName" [nzPlaceHolder]="'Username'" [nzSize]="'large'">
"): ng:///AuthModule/LoginPageComponent.html@23:24
No provider for NgControl (" <div nz-form-control [nzValidateStatus]="validateForm.controls.password">
[ERROR ->]<nz-input formControlName="password" [nzType]="'password'" [nzPlaceHolder]="'Password'" [nzSize]="'la"): ng:///AuthModule/LoginPageComponent.html@33:24
No provider for NgControl ("


[ERROR ->]
Remember me
"): ng:///AuthModule/LoginPageComponent.html@43:24
at syntaxError (http://localhost:4201/vendor.bundle.js:85450:34)
at TemplateParser.webpackJsonp.../../../compiler/@angular/compiler.es5.js.TemplateParser.parse (http://localhost:4201/vendor.bundle.js:96574:19)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileTemplate (http://localhost:4201/vendor.bundle.js:110726:39)
at http://localhost:4201/vendor.bundle.js:110646:62
at Set.forEach (native)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileComponents (http://localhost:4201/vendor.bundle.js:110646:19)
at http://localhost:4201/vendor.bundle.js:110533:19
at Object.then (http://localhost:4201/vendor.bundle.js:85439:156)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (http://localhost:4201/vendor.bundle.js:110532:26)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync

涉及到交互就报这个错误,是我少引入了什么东西了么

@vthinkxie
Copy link
Member

@htmlcss23 read the doc again.
https://ng.ant.design/#/components/form

@htmlcss23
Copy link

htmlcss23 commented Aug 23, 2017

解决了。谢谢

@wilsoncook wilsoncook self-assigned this Aug 28, 2017
wilsoncook added a commit to wilsoncook/ng-zorro-antd that referenced this issue Sep 9, 2017
… "form.reset()"

change the nz-input to not trigger "view -> control updating" while "control -> view updating"

close NG-ZORRO#114
wilsoncook added a commit to wilsoncook/ng-zorro-antd that referenced this issue Sep 9, 2017
…when "form.reset()" called

change the "writeValue" to not trigger "view -> control updating" while "control -> view updating"

close NG-ZORRO#114
vthinkxie pushed a commit that referenced this issue Sep 9, 2017
…when "form.reset()" called (#257)

change the "writeValue" to not trigger "view -> control updating" while "control -> view updating"

close #114
@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants