Commit ec06683ada5da45105e5f3089f9d9d35951a1f67
1 parent
8c203fc8f1
Exists in
master
and in
1 other branch
Agregado el tipo
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/app/services/producto.service.ts
| 1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core'; |
| 2 | import { HttpClient } from '@angular/common/http'; | 2 | import { HttpClient } from '@angular/common/http'; |
| 3 | import { Observable } from 'rxjs'; | 3 | import { Observable } from 'rxjs'; |
| 4 | import { appSettings } from 'src/etc/AppSettings'; | 4 | import { appSettings } from 'src/etc/AppSettings'; |
| 5 | import { Producto } from '../wrappers/producto'; | 5 | import { Producto } from '../wrappers/producto'; |
| 6 | import { EventEmitter } from '@angular/core'; | 6 | import { EventEmitter } from '@angular/core'; |
| 7 | 7 | ||
| 8 | @Injectable({ | 8 | @Injectable({ |
| 9 | providedIn: 'root' | 9 | providedIn: 'root' |
| 10 | }) | 10 | }) |
| 11 | export class ProductoService { | 11 | export class ProductoService { |
| 12 | 12 | ||
| 13 | productos : Producto[] = []; | 13 | productos : Producto[] = []; |
| 14 | productosEvent: EventEmitter<Producto[]> = new EventEmitter(); | 14 | productosEvent: EventEmitter<Producto[]> = new EventEmitter(); |
| 15 | 15 | ||
| 16 | constructor(private http: HttpClient) { } | 16 | constructor(private http: HttpClient) { } |
| 17 | 17 | ||
| 18 | getAll(): Observable<any> { | 18 | getAll(): Observable<any> { |
| 19 | 19 | ||
| 20 | return this.http.get(`${appSettings.apiUrl}/articulos`); | 20 | return this.http.get(`${appSettings.apiUrl}/articulos`); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | setProductos(producto){ | 23 | setProductos(producto : Producto){ |
| 24 | 24 | ||
| 25 | this.productos.push(producto); | 25 | this.productos.push(producto); |
| 26 | this.productosEvent.emit(this.productos); | 26 | this.productosEvent.emit(this.productos); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | } | 29 | } |
| 30 | 30 |