我的回复标题是:
HTTP/1.1 200 OK
Content-Disposition: attachment; filename="file.docx"
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Thu, 26 Apr 2018 10:37:00 GMT
ETag: W/"c61-16301871843"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Length: 3169
Date: Thu, 26 Apr 2018 10:37:00 GMT
Connection: keep-alive
Run Code Online (Sandbox Code Playgroud)
我试过这段代码,
public download(id: string): Observable<Blob> {
let headers = new Headers();
const _baseUrl = (Api.getUrl(Api.URLS.download));
headers.append('x-access-token', this.auth.getCurrentUser().token);
headers.append('sale_id', id);
return this.http.get(_baseUrl, { headers: headers, responseType: ResponseContentType.Blob})
.map((res) => {
console.log(res.headers) // show like in image
return new Blob([res.blob()], { type: 'application/octet-stream' })
});
}
Run Code Online (Sandbox Code Playgroud)
没有显示内容处置! …
我正在为我的项目使用自动完成材料,但我不明白如何使用 [displayWith]。我尝试了一些示例,但不在 html 中显示名称,仅显示 id。
我的html代码:
<form [formGroup]="editClientForm">
<input formControlName="city_id" id="city_id" matInput placeholder="Select City*" aria-label="State" [matAutocomplete]="auto1"
autoActiveFirstOption [formControl]="city">
<mat-autocomplete #auto1="matAutocomplete" [displayWith]="displayFnCity">
<mat-option (onSelectionChange)="updateForm($event, city.city_id, 'city_id')" *ngFor="let city of filteredOptionsCity | async"
[value]="city.name">
{{ city.name }}
</mat-option>
</mat-autocomplete>
</form>
Run Code Online (Sandbox Code Playgroud)
我的 ts 组件:
cityid = 0;
filteredOptionsCity: any;
city: FormControl = new FormControl();
editClientForm: FormGroup;
this.editClientForm = this.fb.group({
'city_id': new FormControl('', Validators.required),
});
ngOnInit() {
this.filteredOptionsCity = this.city.valueChanges.pipe(
startWith(''),
map(value => this.filterCity(value))
);
}
populateForm() {
this.activatedRoute.params.subscribe(
params => {
this.clientService.getClientById(params['id']).subscribe(
client …Run Code Online (Sandbox Code Playgroud)