Currently, I am using Angular4 (4.3.6) in combination with AngularFire2 (4.0.0-rc.2). To retrieve data for a detailed view, I use the following code:
// GET THE ID
this.id = this.route.snapshot.params['id'];
this.subscriptions.push(
this.db.object('/restaurants/' + this.id).subscribe(data => {
this.restaurant = data;
console.log(data);
})
);
Although this approach fetches the data needed, it results in errors being thrown in the console due to the data arriving slightly delayed. Additionally, I prefer not to obtain the id from route.params as I plan to use the object name as a route for the detail view at a later stage.
To access the StackBlitz example, please visit: https://stackblitz.com/edit/angular-7gabaq?file=sites/site-restaurant-detail/site-restaurant-detail.component.ts (Click on "View Restaurant")