App.component.html
Extrato Nova Transferencia ******************************************************************************* nova-transferencia.ts 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; }
}
app.routing.ts
import { NovaTransferenciaComponent } from './nova-transferencia/nova-transferencia.component';
import { ExtratoComponent } from './extrato/extrato.component'; import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [ {path: '',redirectTo:'extrato', pathMatch:'full'}, {path: 'extrato',component: ExtratoComponent }, {path: 'nova-transferencia', component: NovaTransferenciaComponent} ];
export const AppRoutingModule = RouterModule.forRoot(routes);
app.module.ts
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http'; import { DEFAULT_CURRENCY_CODE, LOCALE_ID, NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component'; import { NovaTransferenciaComponent } from './nova-transferencia/nova-transferencia.component'; import { ExtratoComponent } from './extrato/extrato.component'; import { registerLocaleData } from '@angular/common'; import localePt from '@angular/common/locales/pt';
registerLocaleData(localePt, 'pt') @NgModule({ declarations: [ AppComponent, NovaTransferenciaComponent, ExtratoComponent ], imports: [ BrowserModule, FormsModule, HttpClientModule, AppRoutingModule ], providers: [ {provide: LOCALE_ID, useValue: 'pt'}, { provide: DEFAULT_CURRENCY_CODE, useValue: 'BRL' } ], bootstrap: [AppComponent] }) export class AppModule { }