Skip to content

Instantly share code, notes, and snippets.

@JoseRFJuniorLLMs
Last active March 11, 2019 08:05
Show Gist options
  • Select an option

  • Save JoseRFJuniorLLMs/ee4013f043e4feb5a9e625f9e0945e03 to your computer and use it in GitHub Desktop.

Select an option

Save JoseRFJuniorLLMs/ee4013f043e4feb5a9e625f9e0945e03 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router'
import {RestaurantsService} from '../restaurants/restaurants.service'
import {Restaurant} from '../restaurants/restaurant/restaurant.model'
@Component({
selector: 'mt-restaurant-detail',
templateUrl: './restaurant-detail.component.html'
})
export class RestaurantDetailComponent implements OnInit {
restaurant: Restaurant
constructor(private restaurantsService: RestaurantsService,
private route: ActivatedRoute) { }
ngOnInit() {
this.restaurantsService.restaurantById(this.route.snapshot.params['id'])
.subscribe(restaurant => this.restaurant = restaurant)
}
}
////////////////////////////////XD/////////////////////////////////
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router'
import {RestaurantsService} from '../../restaurants/restaurants.service'
import {Observable} from 'rxjs/Observable'
@Component({
selector: 'mt-reviews',
templateUrl: './reviews.component.html'
})
export class ReviewsComponent implements OnInit {
reviews: Observable<any>
constructor(private restaurantsService: RestaurantsService,
private route: ActivatedRoute) { }
ngOnInit() {
this.reviews = this.restaurantsService
.reviewsOfRestaurant(this.route.parent.snapshot.params['id'])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment