import { Headers, Http } from '@angular/http';
@Injectable()
export class PublisherService{
private publishersUrl = 'app/publisher';
constructor(private http: Http) { }
getPublishers(): Promise<Publisher[]>{
return this.http.get(this.publishersUrl)
.toPromise()
.then(response => response.json().data)
.catch(this.handleError);
}
}
我收到这个错误:
Property 'toPromise' does not exist on type 'Observable'.any
最佳答案
您需要像这样添加运算符:
import 'rxjs/add/operator/toPromise';
这是您要使用的每个 rxjs 运算符所必需的。
关于angular - 类型 'toPromise' 上不存在属性 'Observable<Response>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38090989/