我有一个 Angular 4 的自动完成组件的代码:
在 FormGroup 中有一个 FormControl,它与 html 相关联,并且它能够完美地工作。
this.ProfileForm.controls["code"]
当我在文本框中更改时,valueChanges事件会触发。但是,当我通过编程方式更新formcontrol值时,valueChanges事件不会触发。
以下是我编写的代码行。
this.ProfileForm.controls["code"].setValue("someValue");
this.ProfileForm.controls["code"].valueChanges.subscribe(() => {
console.log("modified");}, () => { console.log("error") }, () => { console.log("completed") });
任何建议都受到赞赏。