在这个回答中,有人向我解释了使用selectItem来获取选择事件。但是此时,我绑定到文本框的模型仍然是用户输入的原始文本,而不是选择项。
我使用了。
我使用了。
(selectItem)="search(model)"
获取事件,在TS中
search(model) {
this._service.search(model).subscribe(
results => this.results = results,
error => this.errorMessage = <any>error);
但是如上所述,这将使用用户键入的文本调用我的后端,而不是typeahead选定项目的完整文本。
我的后端记录
2017/03/24 20:44:14 /api/typeahead/ok
2017/03/24 20:44:14 /api/search/ok
第二个应该是 /api/search/$actualSelectedItem。