[英]InvalidPipeArgument: '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],
I am trying to load service data in ngfor through async pipe but i am facing an issue: this is my component: 我正在尝试通过异步管道在ngfor中加载服务数据,但是我遇到了一个问题:这是我的组件:
<app-book-list *ngFor="let app of apps | async | serachBox:searchBooksByName | filterSearch:showTechBooks:showMgmBooks:showFictionBooks "
[bookdetails]="app"></app-book-list>
In this component apps is supposed to come from service. 在此组件中,应用程序应该来自服务。
In My component.ts file: 在我的component.ts文件中:
public apps= [];
ngOnInit() {
this.ServerService.getBookDetails()
.then((data)=>{
this.apps = data;
})
}
And below is the promise: 以下是承诺:
getBookDetails(){ getBookDetails(){
let promise = new Promise((resolve,reject)=>{
return this.http.get('https://lib-http-ng.firebaseio.com/bookdetails.json')
.toPromise()
.then((res)=>{
const data = Object.values(res.json());
resolve(data[0])
})
})
return promise;
} I am getting an error related to async pipe. 我收到与异步管道有关的错误。
1. 1。
Type '{}' is not assignable to type 'Promise<any>'.
this.ServerService.getBookDetails()
.then((data)=>{
console.log(data);
this.apps = data;
})
should be 应该
this.apps = this.ServerService.getBookDetails()
or remove | async
或删除| async
| async
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.