这是堆栈跟踪:
TypeError: this.validator is not a function app.component.ts:35
at FormControl.AbstractControl._runValidator (forms.es5.js:2720)
at FormControl.AbstractControl.updateValueAndValidity (forms.es5.js:2688)
at new FormControl (forms.es5.js:3011)
at FormBuilder.control (forms.es5.js:5863)
at FormBuilder._createControl (forms.es5.js:5905)
at eval (forms.es5.js:5887)
at Array.forEach (<anonymous>)
at FormBuilder._reduceControls (forms.es5.js:5886)
at FormBuilder.group (forms.es5.js:5845)
at ProfileSettingsComponent.init (profile-settings.component.ts:318)
打开用户设置页面时出现此错误。正如您可以在profile-settings.componenet.ts中的第318行的堆栈跟踪中看到的那样,只有FormBuilder的第一行。而且我不明白FormBuilder和在app.componenet.ts中获取用户对象之间是什么关系。
app.component.ts:
this.sub = this.userService.getLoggedUser()
.subscribe(res => {
console.info('From app: ', res.body.user);
this.loadVideoChatInviter = true;
}, err => {
console.error(err); // line 35
});
profile-settings.component.ts:
this.userSettingsToUpdate = this.fb.group({ // line 318
'firstName': this.user.firstName,
'lastName': this.user.lastName,
'email': this.user.email,
'gender': this.genderItems,
// ...
'newPassword': ['', Validators.minLength(6)],
'confirmedPassword': ['', Validators.minLength(6)],
// ...
});