我正在尝试在Angular5中使用ng2完成器。然而,我不能张贴自定义标题与它。我正在尝试复制this
我的HTML代码如下:
<ng2-completer [inputClass]="{'form-control': true, 'has-error': !Name.valid && Name.touched}"
[(ngModel)]="searchStr"
[datasource]="dataService"
formControlName="Name"
[minSearchLength]="3"
autoMatch="true"
clearUnselected="true"></ng2-completer>我的组件如下:
protected searchStr: string;
headers: any;
protected dataService: RemoteData;`
constructor(private completerService: CompleterService, private url: UrlService) {
this.headers = new Headers();
const options = new RequestOptions({ headers: this.headers });
options.headers.set('Content-Type', 'application/json');
options.headers.set('Authorization', 'xxx');
this.dataService = completerService.remote(url.data_url, 'name', 'name');
this.dataRemote.requestOptions(options);
}这个不会发送我的身份验证令牌。有谁能帮我吗?谢谢
发布于 2018-04-11 05:16:54
试着在你的组件中这样做:
constructor(private completerService: CompleterService, private url: UrlService) {
this.dataService = completerService.remote(url.data_url, 'name', 'name');
let options = new RequestOptions({headers: new Headers()});
options.headers.set('Authorization','xxx');
options.headers.set('Content-Type', 'application/json');
this.dataRemote.requestOptions(options);
}这个实现对我很有效!!
https://stackoverflow.com/questions/49059307
复制相似问题