我遇到了错误:
TS2339:类型“Subscription”上不存在属性“pipe”
出错代码行在下方标注的“HERE”处。
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Source } from '../model/source';
import { map } from 'rxjs/operators';
import { Entry } from '../model/entry';
@Injectable()
export class SourcesService {
private readonly API_URL = 'https://localhost:44384';
constructor(private http: HttpClient) { }
findEntries(
sourceId: number, filter = '', sortOrder = 'asc',
pageIndex = 0, pageSize = 3): Observable<Entry[]> {
return this.http.get(`${this.API_URL}/api/entries`, {
params: new HttpParams()
.set('sourceId', sourceId.toString())
.set('filter', filter)
.set('sortOrder', sortOrder)
.set('pageIndex', pageIndex.toString())
.set('pageSize', pageSize.toString()),
observe: 'response'
}).subscribe((res: any) => {
const counter = JSON.parse(res.headers.get('X-Pagination')).totalCount;
}).pipe( // <<<=========================================================== HERE
map((res: any) => {
res['playload'] = res;
return res['playload'];
})
);
}
环境:
Angular CLI: 7.0.3
Node: 10.13.0
OS: win32 x64
Angular: 7.0.1