2023-02-24 13:54:17 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
import { Pokemon } from '../pokemon';
|
2023-02-24 14:12:39 +00:00
|
|
|
import { PokemonService } from '../pokemon.service';
|
2023-02-24 13:54:17 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-detail-pokemon',
|
|
|
|
templateUrl: './detail-pokemon.component.html',
|
|
|
|
})
|
|
|
|
export class DetailPokemonComponent implements OnInit {
|
2023-02-24 14:12:39 +00:00
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
|
|
|
private pokemonService: PokemonService
|
|
|
|
) {}
|
2023-02-24 13:54:17 +00:00
|
|
|
pokemonList: Pokemon[];
|
|
|
|
pokemon: Pokemon | undefined;
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
const pokemonId: string | null = this.route.snapshot.paramMap.get('id');
|
|
|
|
if (pokemonId) {
|
2023-02-24 14:12:39 +00:00
|
|
|
this.pokemon = this.pokemonService.getPokemonById(+pokemonId);
|
2023-02-24 13:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goToPokemonList() {
|
|
|
|
this.router.navigate(['/pokemons']);
|
|
|
|
}
|
|
|
|
}
|