import { Transferencia } from './../models/transferencia.model'; import { TransferenciasService } from '../services/transferencias.service'; import { Component, OnInit } from '@angular/core';
@Component({ selector: 'app-extrato', templateUrl: './extrato.component.html', styleUrls: ['./extrato.component.scss'] }) export class ExtratoComponent implements OnInit {
transferencias: any[] = [];
constructor(private service:TransferenciasService) { }
import { TransferenciasService } from './../services/transferencias.service'; import { Transferencia } from './../models/transferencia.model'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit, Output } from '@angular/core'; import { EventEmitter } from '@angular/core';
@Component({ selector: 'app-nova-transferencia', templateUrl: './nova-transferencia.component.html', styleUrls: ['./nova-transferencia.component.scss'], }) export class NovaTransferenciaComponent implements OnInit {
@Output() aoTransferir = new EventEmitter();
valor: number;
destino: number | string;
constructor(private service: TransferenciasService) {}
ngOnInit() {}
transferir() { console.log('Solicitado nova transferência'); const valorEmitir = {Valor: this.valor, Destino:this.destino}; this.service.adicionar(valorEmitir).subscribe(resultado =>{ console.log(resultado) this.limparCampos(); }, error => console.error(error));
}
limparCampos(){ this.valor = 0; this.destino = 0; }
}
ngOnInit() {
this.service.todas().subscribe((transferencias: Transferencia[] ) =>{ console.table(transferencias); this.transferencias = transferencias; //Transferencias da classe, recebe transferencias de parametros }); }
}
@Component({
selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) export class AppComponent { title = 'ByteBank';
constructor(private service: TransferenciasService) {}
}