Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angular2中的抽象控制_Angular_Ionic2 - Fatal编程技术网

angular2中的抽象控制

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

我在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, 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;