gpt4 book ai didi

angular - ng2-completer-生产版本中产生错误

转载 作者:行者123 更新时间:2023-12-02 10:42:34 25 4
gpt4 key购买 nike

我正在使用ng2-completer创建一个搜索框,用户可以在其中搜索github用户名。我已经使用CompleterService,CompleterData从API获取数据。

Component.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中产生错误。

最佳答案

将completerData更改为RemoteData即可。

import { CompleterService, CompleterData, RemoteData } from 'ng2-completer';

searchStr: string;
dataService: RemoteData;

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');
}

这很好。

关于angular - ng2-completer-生产版本中产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51807202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com