Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 25, 2019 21:47
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 parzibyte/1c7b5e4a8da913b33358e04d5f379bfa to your computer and use it in GitHub Desktop.
Save parzibyte/1c7b5e4a8da913b33358e04d5f379bfa to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { Mascota } from '../mascota';
import { MascotasService } from "../mascotas.service"
import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
@Component({
selector: 'app-agregar-mascota',
templateUrl: './agregar-mascota.component.html',
styleUrls: ['./agregar-mascota.component.css']
})
export class AgregarMascotaComponent implements OnInit {
constructor(private mascotasService: MascotasService,
private snackBar: MatSnackBar,
private router: Router,
) { }
ngOnInit() {
}
mascotaModel = new Mascota("", "", undefined)
onSubmit() {
this.mascotasService.addMascota(this.mascotaModel).subscribe(() => {
this.snackBar.open('Mascota guardada', undefined, {
duration: 1500,
});
this.router.navigate(['/mascotas']);
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment