2017-12-11 6 views
1

양식이 유효한지 확인한 후이 오류 ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.을 reactiveform에서 가져 오십시오.각도 4 표정을 확인한 후에 변경됨 오류

creatForm

public createForm() { 
    this.loginForm = new FormGroup({ 
     email: new FormControl('', [ 
     Validators.required, 
     this.patternValidator(/^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/) 
     ]), 
     password: new FormControl('', [ 
     Validators.required, 
     Validators.minLength(6) 
     ]) 
    }); 
    this.guestForm = new FormGroup({ 
     guestName: new FormControl('', [ 
     Validators.required 
     ]), 
     guestCode: new FormControl('', [ 
     Validators.required, 
     Validators.minLength(8) 
     ]) 
    }); 
    } 

이 각도로 이메일 필드 검증 지금 형태

<form [formGroup]="loginForm" (ngSubmit)="couplelogin(user)" novalidate> 
     <div id="couple_login_form" class="login-form"> 
     <div class="login-field" [ngClass]="{'pattern' : !loginForm.controls.email.valid && loginForm.controls.email.touched, 'error' : loginForm.controls.email.pristine && loginForm.controls.email.touched, 'focus' : loginForm.controls.email.dirty}"> 
      <label for="email_login" translate="HOME.EMAIL_FORM">E-Mail</label> 
      <input type="email" formControlName="email" [(ngModel)]="user.email" name="email"> 
      <div class="message text-center"> 
      <p translate="HOME.FORM_REQUIRED">This field is required</p> 
      </div> 
      <div class="pattern text-center"> 
      <p translate="HOME.ERROR_FORMAT">Enter a valid email.</p> 
      </div> 
     </div> 
     <div class="login-field" [ngClass]="{'error' : loginForm.controls.password.pristine && loginForm.controls.password.touched, 'focus' : loginForm.controls.password.dirty}"> 
      <label for="pass_login" translate="HOME.PASSWOR_FORM">Password</label> 
      <input type="password" [(ngModel)]="user.password" name="password" formControlName="password"> 
      <div class="message text-center"> 
      <p translate="HOME.FORM_REQUIRED">This field is required</p> 
      </div> 
     </div> 
     <p class="text-center bottom-msg-login" translate="HOME.FORM_MESSAGE">Don't have an account yet? Download the app für Android or iOS, sign in and create your wedding!</p> 
     <button class="submit" type="submit" name="couple" [disabled]="!loginForm.valid" translate="HOME.LOGIN">Login</button> 
     </div> 
    </form> 

, 사용자의 인증에 대한 미안 사용 중포 기지, 미안 인 4,하지만 내가 전자 우편 formart가 firebase와 올바른지 확인 유효성 검사를하면 오류가 사라졌습니다, 어떤 생각.

답변

1

확인 이메일의 경우이 하나

'email': [null, [ 
     Validators.required, Validators.email 
    ]], 

이 모든 [(ngModel)]="user.XXX"name="XXX"

를 제거하고 난 여전히 그런 식으로하지만 이메일의 검증을 만들기 위해 노력하고

<form [formGroup]="loginForm" (ngSubmit)="couplelogin(loginForm.value)"> 
+0

변경 할 수 있습니다 동일한 오류가 발생합니다. –

+0

문제가 '[(ngModel)] = "user.XXX"'였으므로 삭제하고 양식을

() \ [\] \\.,; : \ s @"] + (\. [^ <> (..) ..' –