Skip to content

Instantly share code, notes, and snippets.

View NyaGarcia's full-sized avatar
🐈

Nya NyaGarcia

🐈
View GitHub Profile
<div class="container">
<div class="header">
<img src="assets/NgPokedex.png" />
</div>
<div class="content">
<div class="list">
<div class="list-header">
<h3>List of Pokemon</h3>
<button mat-raised-button color="primary" (click)="addPokemon()">
Add Pokemon
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Observable } from 'rxjs';
import { PokedexFirestoreService } from 'src/app/core/pokedex-firestore.service';
import { Pokemon } from './interfaces/pokemon.interface';
@Component({
selector: 'app-pokemon',
templateUrl: './pokemon.component.html',
import { Component, OnInit } from '@angular/core';
import { Observable, filter, tap } from 'rxjs';
import { FormComponent } from './components/form/form.component';
import { MatDialog } from '@angular/material/dialog';
import { PokedexFirestoreService } from 'src/app/core/pokedex-firestore.service';
import { Pokemon } from './interfaces/pokemon.interface';
@Component({
selector: 'app-pokemon',
<form [formGroup]="form">
<mat-form-field>
<mat-label>Name</mat-label>
<input required formControlName="name" class="form-control" placeholder="Charmander" type="text" matInput />
</mat-form-field>
<mat-form-field>
<mat-label>Type</mat-label>
<input required formControlName="type" class="form-control" placeholder="Fire" type="text" matInput />
</mat-form-field>
<mat-form-field>
@NyaGarcia
NyaGarcia / form.component.ts
Last active June 10, 2022 13:33
Creating the pokemon form dialog
import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Pokemon } from '../../interfaces/pokemon.interface';
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'],
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { NgModule } from '@angular/core';
import { PokemonComponent } from './pokemon.component';
import { PokemonRoutingModule } from './pokemon-routing.module';
import { ReactiveFormsModule } from '@angular/forms';
@NyaGarcia
NyaGarcia / list.component.ts
Last active May 20, 2022 15:29
Pokemon list component
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Observable } from 'rxjs';
import { Pokemon } from '../../interfaces/pokemon.interface';
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.scss'],
})
@NyaGarcia
NyaGarcia / list.component.html
Created May 20, 2022 10:49
Creating the Pokemon list
<div class="card-container">
<mat-card
*ngFor="let pokemon of pokemon$ | async"
(click)="selectPokemon(pokemon)"
>
<mat-card-header>
<mat-card-title>{{ pokemon.name }}</mat-card-title>
<mat-card-subtitle>{{ pokemon.type }} type</mat-card-subtitle>
</mat-card-header>
<img mat-card-image [src]="pokemon.imgUrl" alt="Photo of a Pokemon" />
@NyaGarcia
NyaGarcia / pokedex-firestore.service.ts
Last active June 17, 2022 10:55
Implementing CRUD functions
import {
CollectionReference,
DocumentData,
addDoc,
collection,
deleteDoc,
doc,
updateDoc,
} from '@firebase/firestore';
import { Firestore, collectionData, docData } from '@angular/fire/firestore';
import {
CollectionReference,
DocumentData,
collection,
} from '@firebase/firestore';
import { Firestore } from '@angular/fire/firestore';
import { Injectable } from '@angular/core';
@Injectable({