ng-pokemon-app/src/app/app.component.ts

21 lines
518 B
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core';
import { POKEMONS } from './mock-pokemon-list';
import { Pokemon } from './pokemon';
2023-02-22 13:12:40 +00:00
@Component({
selector: 'app-root',
template: `<h1>Liste de Pokémons</h1>`,
2023-02-22 13:12:40 +00:00
})
export class AppComponent implements OnInit {
pokemonList: Pokemon[] = POKEMONS;
ngOnInit() {
console.table(this.pokemonList);
this.selectPokemon(this.pokemonList[0]);
}
selectPokemon(pokemon: Pokemon) {
console.log(`Vous avez cliqué sur le pokémon ${pokemon.name}`);
}
2023-02-22 13:12:40 +00:00
}