我有以下代码
ngOnInit() {
this.contactsService.getContactByAuthId(this.user.id).subscribe(profile => {
this.profile = profile;
this.profileForm = this.formBuilder.group({
name: [this.profile.name, Validators.compose([Validators.minLength(6), Validators.required])],
title: [this.profile.title, Validators.compose([Validators.minLength(6), Validators.required])],
});
this.profileForm.title.valueChanges.subscribe(value => {
console.log(value);
});
});
}
我想订阅valueChangesof title,但Cannot read property 'valueChanges' of undefined出现错误。
我可以订阅,this.profileForm.valueChanges但我想在标题更改时进行某种去抖动和 api 调用。
看来,如果您有FormControl,您将能够订阅它的更改,但由于我使用的是FormBuilder语法,所以我无权访问FormControl.