Created
November 11, 2019 00:00
-
-
Save parzibyte/d90a0e2802df49b6d5188be761c59d49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "@angular/core"; | |
import { PersonasService } from "./personas.service"; | |
import {Persona} from "./persona" | |
@Component({ | |
selector: "my-app", | |
templateUrl: "./app.component.html", | |
styleUrls: ["./app.component.css"] | |
}) | |
export class AppComponent { | |
respuesta = {}; | |
constructor(private personasService: PersonasService) {} | |
probarGet() { | |
this.respuesta = { mensaje: "Cargando..." }; | |
this.personasService | |
.obtener() | |
.subscribe((personas: Persona) => { | |
this.respuesta = personas; | |
console.log(personas); | |
}); | |
} | |
probarPost() { | |
let persona = new Persona("John Galt", 21); | |
this.respuesta = { mensaje: "Cargando..." }; | |
this.personasService.registrar(persona).subscribe(datos => { | |
this.respuesta = datos; | |
}); | |
} | |
probarPut() { | |
let persona = new Persona("Dagny Taggart", 19); | |
this.respuesta = { mensaje: "Cargando..." }; | |
this.personasService.actualizar(persona).subscribe(datos => { | |
this.respuesta = datos; | |
}); | |
} | |
probarDelete() { | |
let idPersona = 281196; | |
this.respuesta = { mensaje: "Cargando..." }; | |
this.personasService.eliminar(idPersona).subscribe(datos => { | |
this.respuesta = datos; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment