import { Component, OnInit } from '@angular/core'; import { _HttpClient } from '@delon/theme'; import {FormBuilder, FormGroup, Validators, FormControl} from '@angular/forms'; @Component({ selector: 'app-sucu02-form0010001', templateUrl: './sucu02-form0010001.component.html', }) export class Sucu02Form0010001Component implements OnInit { validateForm: FormGroup; submitForm(): void { for (const i in this.validateForm.controls) { this.validateForm.controls[ i ].markAsDirty(); this.validateForm.controls[ i ].updateValueAndValidity(); } } updateConfirmValidator(): void { /** wait for refresh value */ Promise.resolve().then(() => this.validateForm.controls.checkPassword.updateValueAndValidity()); } confirmationValidator = (control: FormControl): { [s: string]: boolean } => { if (!control.value) { return { required: true }; } else if (control.value !== this.validateForm.controls.password.value) { return { confirm: true, error: true }; } } getCaptcha(e: MouseEvent): void { e.preventDefault(); } constructor(private fb: FormBuilder) { } ngOnInit(): void { this.validateForm = this.fb.group({ email : [ null, [ Validators.email ] ], password : [ null, [ Validators.required ] ], checkPassword : [ null, [ Validators.required, this.confirmationValidator ] ], nickname : [ null, [ Validators.required ] ], phoneNumberPrefix: [ '+86' ], phoneNumber : [ null, [ Validators.required ] ], website : [ null, [ Validators.required ] ], captcha : [ null, [ Validators.required ] ], agree : [ false ] }); } }