import { Component, OnInit } from '@angular/core'; import {RestaurantesService} from "../../restaurantes.service"; @Component({ selector: 'app-agregar-usuario', templateUrl: './agregar-usuario.component.html', styleUrls: ['./agregar-usuario.component.scss'] }) export class AgregarUsuarioComponent implements OnInit { usuarios: any; agreU={ nombre:null, email:null, username:null, password:null, roles:['admin'], restaurant:null } modi={ nombre: null, roles:['productor'] } constructor(private restaurantServ : RestaurantesService) { } ngOnInit(): void { this.recuperarUsuarios(); } recuperarUsuarios(){ this.restaurantServ.mostrarUsuarios().subscribe(result => this.usuarios = result) } AgregarUsu(){ this.restaurantServ.agregarUsu(this.agreU).subscribe(this.recuperarUsuarios) } eliminarUsu(id:any){ if(confirm("Esta seguro de eliminar este registro?")){ this.restaurantServ.eliminarUsu(id).subscribe(); } } modificarUsu(id:any){ this.restaurantServ.moficiarUsu(id,this.modi).subscribe(); } }