Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active July 10, 2023 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/f301f6c5621388d9fdf33dbc7cd77ef1 to your computer and use it in GitHub Desktop.
Save NyaGarcia/f301f6c5621388d9fdf33dbc7cd77ef1 to your computer and use it in GitHub Desktop.
NgBytes Standalone Pokemon List
import { Component, OnInit } from '@angular/core';
import { Pokemon, PokemonService } from '../pokemon.service';
import { CommonModule } from '@angular/common';
import { PokemonCardComponent } from '../pokemon-card/pokemon-card.component';
import { Router } from '@angular/router';
@Component({
selector: 'ngbytes-pokemon-list',
standalone: true,
imports: [CommonModule, PokemonCardComponent],
templateUrl: './pokemon-list.component.html',
styleUrls: ['./pokemon-list.component.css'],
})
export class PokemonListComponent implements OnInit {
pokemonList: Pokemon[];
constructor(
private readonly pokemonService: PokemonService,
private readonly router: Router
) {
this.pokemonList = this.pokemonService.getAll();
}
openDetailsPage(id: string) {
this.router.navigate(['details/', id]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment