Open pedrolucasoliva opened 7 years ago
@pedrolucasoliva Also having this issue. I managed to get around it by directly accessing the _value
property within the Observable.
[mfData]="yourObservable.source._value"
It would be great if mfData
accepted an Observable, just like *ngFor
does.
Nevermind – figured it out. You need to use the async
pipe to subscribe to an observable or promise. It then unwraps the value each time it updates.
<table [mfData]="topics | async">
It takes half of day to work around and finally easily to integrate AngularFirestore and Angular2-datatable. I hope this help.
//Component code
export class AppComponent {
items: Observable<any[]>;
constructor(db: AngularFirestore) {
this.items = db.collection('items').valueChanges();
}
}
//HTML code
<table class="table table-striped" [mfData]="items | async" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
...
code everything
...
<tr *ngFor="let item of mf.data">
That 's all. Don't add anything into *ngFor , I guess mfData take over for this. Thanks for reading.
The [mfData] propertie needs a JSON list.
How can I put my AngularFire2 FirebaseListObservable to work with angular2-datatable? Someone did it?