我有一个窗体,它有一个输入字段,可以输入一个类型。我正在从API调用中获取一个JSON对象数组:
allPeople = [{"id":1,"first_name":"Abba","last_name":"Lee","current_position":"Travel Expert"}, {"id":2,"first_name":"Abbey","last_name":"Joe","current_position":"water keeper"}]
但是当我开始打字的时候
[object object]
这就是我现在拥有的:
<input formControlName="person" [typeahead]="allPeople" [typeaheadOptionsLimit]="10" [typeaheadMinLength]="0" type="text">
我尝试过:
<input formControlName="person" [typeahead]="inf as inf.first_name for inf in allPeople | filter:{first_name:$viewValue}" [resultFormatter]="formatMatches" [inputFormatter]="formatMatches" [typeaheadOptionsLimit]="10" [typeaheadMinLength]="0" type="text">
但我得到了一个错误:
Uncaught Error: Template parse errors:
Parser Error: Unexpected token 'as' at column 5 in [inf as inf.first_name for inf in allPeople | filter:{first_name:$viewValue}] in ...
当我开始输入时,如何获取输入以显示/建议我的名字和姓氏?