且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Angular 世界之外发生更改时更新 Angular 2 反应式表单字段

更新时间:2023-02-12 11:24:10

Inside Directive :

Inside Directive :

您可以使用@Output 发送事件并以形式捕获它

You can use @Output to send an event and capture it in the form

@Output typeaheadResult = new EventEmitter(); 

...

// Whenever user selects a result dispatch the event 
this.typeaheadResult.emit(changedInput);

在您的 HTML 中,您可以捕获它


Inside your HTML you can capture it

 <input formControlName="name"
          myTypeahead="'http://someRemoteUrl'"
          (typeaheadResult)="doSomething()"
           />