File

src/app/detail/detail.page.ts

Metadata

selector app-detail
styleUrls detail.page.scss
templateUrl detail.page.html

Constructor

constructor(placeService: PlacesService, route: ActivatedRoute, router: Router)

Methods

toggleFavourite
toggleFavourite(place: Place)
Returns: void

Properties

place
place: Place
import { Component} from '@angular/core';
import {Place} from "../Place";
import {PlacesService} from "../api/places.service";
import {ActivatedRoute, Router} from "@angular/router";

@Component({
  selector: 'app-detail',
  templateUrl: './detail.page.html',
  styleUrls: ['./detail.page.scss'],
})
export class DetailPage {

  place: Place;

  constructor(private placeService: PlacesService,private route: ActivatedRoute, private router: Router) {

    this.route.queryParams.subscribe(_p => {
      const navParams = this.router.getCurrentNavigation().extras.state
      if (navParams) this.place = navParams.place;
    })

  }

  toggleFavourite(place: Place){
    place.isFavourite = !place.isFavourite
    this.placeService.toggleFavourite(place).subscribe((place) => this.place = place);
  }


}

results matching ""

    No results matching ""