angular2中的抽象控制
我在ts文件中尝试了AbstractControl,在构建应用程序时,它的shows error属性不存在{[key:string]:any}AbstractControl ts文件:-angular2中的抽象控制,angular,ionic2,Angular,Ionic2,我在ts文件中尝试了AbstractControl,在构建应用程序时,它的shows error属性不存在{[key:string]:any}AbstractControl ts文件:- errors: ( {[ FormGroup : string ] : void} ) getError(errorCode: string): any { return isPresent(this.control) ? this.control.getError(errorCode, thi
errors: ( {[ FormGroup : string ] : void} )
getError(errorCode: string): any {
return isPresent(this.control) ? this.control.getError(errorCode, this.path) : null;
}
hasError(errorCode: string): boolean {
return isPresent(this.getError(errorCode, this.path));
}
this.myForm = new FormGroup({
'firstname' : new FormControl('',[Validators.required,Validators.minLength(3)]),
'lastname' : new FormControl('', [Validators.required,Validators.minLength(1)]),
'useridphone' : new FormControl('', Validators.required),
'password' : new FormControl('',Validators.compose([Validators.required,Validators.minLength(4),
Validators.pattern(this.passwordRegex)])),
'confirmpassword': new FormControl('',Validators.required),
'email' : new FormControl( '', Validators.compose([ Validators.required, Validators.pattern(this.emailRegex) ]) )
}
如何为这些字段编写abstractcontrol
export class FormGroup extends AbstractControl {
constructor(
public controls: {[key: string]: AbstractControl},
validator: ValidatorFn = null,
asyncValidator: AsyncValidatorFn = null
) {
super(validator, asyncValidator);
this._initObservables();
this._setUpControls();
this.updateValueAndValidity({onlySelf: true, emitEvent: false});
}
//...
}
您可以进一步查看您的
类FormGroup
在哪里?导出类SinupPage{myForm:FormGroup;