I've inadvertently changed some code somewhere and now my posts are no longer being pulled through, can anyone spot the mistake?
Service:
posts: AngularFirestoreCollection<any[]>;
constructor(private db: AngularFirestore) { }
getPosts() {
this.posts = this.db.collection('/posts') as AngularFirestoreCollection<any[]>;
return this.posts;
}
}
Post Component:
posts: AngularFirestoreCollection<any>;
constructor(private firebaseService: FirebaseService) { }
ngOnInit() {
this.posts = this.firebaseService.getPosts();
}
}
Post HTML:
<mat-grid-tile *ngFor="let post of posts">
<mat-card class="mat-elevation-z4">
<img mat-card-image src="{{post.imgUrl}}">
<mat-card-actions>
<button mat-icon-button><mat-icon>thumb_up_alt</mat-icon></button><span class="counter mat-small">{{post.numberOfLikes}}</span>
<button mat-icon-button><mat-icon>star</mat-icon></button><span mat-small class="counter mat-small">{{post.numberOfSaves}}</span>
</mat-card-actions>
</mat-card>
</mat-grid-tile>
</mat-grid-list>``
Now I'm getting Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
*ngFor="let post of posts | async"
– Ashish RanjanInvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
– FullerPrimethis.db.collection('/posts') as AngularFirestoreCollection<any[]>
? – porgongfor only supports binding to iterables
. Check the response of service call and content ofposts
to resolve the issue – Gangadhar JANNU