Files
airport-chengdu-web/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.ts
T

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-11-20 18:29:13 +08:00
import { Component, OnInit } from '@angular/core';
import { FormBuilder,FormControl,FormGroup,Validators} from '@angular/forms';
@Component({
selector: 'app-user-management-modify',
templateUrl: './user-management-modify.component.html',
styleUrls: ['./user-management-modify.component.scss','../../../main.scss']
})
export class UserManagementModifyComponent implements OnInit {
validateForm: FormGroup;
constructor(
private fb: FormBuilder
) { }
ngOnInit() {
this.validateForm = this.fb.group({
real_name:[ null, [ Validators.required ] ],
loginId:[ null, [ Validators.required ] ],
password:[ null, [ Validators.required ] ],
identify_num:[ null],
email:[ null],
mobile:[ null],
});
}
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 };
}
};
}