Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(fb: FormBuilder)
- {
- this.form = fb.group({
- password: ['', Validators.required,this.asyncValidator],
- confirmPassword: ['', Validators.required,this.asyncValidator]
- })
- }
- asyncValidator(control:FormControl):any{
- return new Promise(
- (resolve) =>{
- setTimeout(() => {
- if((control.password).length < 6 && (control.password).length > 1)
- console.log("true");
- console.log("false");
- resolve(null);
- },2000);
- }
- );
- }
- <div class="alert alert-danger"
- *ngIf="asyncValidator(this.form.controls.password)">Password too short</div>
Add Comment
Please, Sign In to add comment