From your service, just return the FirebaseListObservable
to your component.
@Injectable()
export class ExpenseService {
public users: FirebaseListObservable<any[]>;
constructor(private afDB: AngularFireDatabase){
this.users = this.afDB.list('/users');
}
getUsers() {
return this.users ;
}
}
and then,
constructor(private _service: YourService) {
_service.getUsers()
.subscribe(users=>{
// do something...
})
}
and use ngFor
<li *ngFor="let user of users | async">
{{ user.displayName}}
</li>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.