Guest User

Untitled

a guest
Dec 9th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. constructor(fb: FormBuilder)
  2. {
  3. this.form = fb.group({
  4. password: ['', Validators.required,this.asyncValidator],
  5. confirmPassword: ['', Validators.required,this.asyncValidator]
  6. })
  7. }
  8.  
  9. asyncValidator(control:FormControl):any{
  10. return new Promise(
  11. (resolve) =>{
  12. setTimeout(() => {
  13. if((control.password).length < 6 && (control.password).length > 1)
  14. console.log("true");
  15. console.log("false");
  16. resolve(null);
  17. },2000);
  18. }
  19. );
  20. }
  21.  
  22. <div class="alert alert-danger"
  23. *ngIf="asyncValidator(this.form.controls.password)">Password too short</div>
Add Comment
Please, Sign In to add comment