我正在使用 ng2-completer 创建一个搜索框,用户可以在其中搜索 github 用户名。我使用 CompleterService、CompleterData 从 API 获取数据。
组件.ts
protected searchStr: string;
protected captain: string;
protected dataService: CompleterData;
constructor(private completerService: CompleterService) {
this.dataService = completerService.remote(null, 'login', 'login');
this.dataService.urlFormater((term: any) => {
return `https://api.github.com/search/users?q=${term}&per_page=5`;
});
this.dataService.dataField('items');
}
.html 文件:
<ng2-completer [(ngModel)]="searchStr" [datasource]="dataService" [minSearchLength]="3" inputClass="form-control"></ng2-completer>
错误 :
ERROR in src/app/search-box/search-box.component.ts(18,22):
error TS2339:
Property 'urlFormater' does not exist on type 'CompleterData'.
src/app/search-box/search-box.component.ts(21,22):
error TS2339: Property
'dataField' does not exist on type 'CompleterData'.
但是开发版本工作正常,但仍然在cmd中产生错误。