Olá, estou recebendo erro no terminal.
Se eu deixo o meu código assim o terminal reclama que não consegue encontrar o nome Transferencias.
import { TransferenciaService } from './../services/transferencia.service';
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-extrato',
templateUrl: './extrato.component.html',
styleUrls: ['./extrato.component.scss'],
})
export class ExtratoComponent implements OnInit {
@Input() transferencias: any[] = [];
constructor(private service: TransferenciaService) {}
ngOnInit(): void {
this.service.todas().subscribe((transferencias: Transferencias[]) => {
console.table(transferencias);
this.transferencias = transferencias;
});
}
}
Se eu faço o import do TransferenciaService gera 3 erros.
import { TransferenciaService } from './../services/transferencia.service';
import { Component, Input, OnInit } from '@angular/core';
import { TransferenciaService } from '../services/transferencia.service';
@Component({
selector: 'app-extrato',
templateUrl: './extrato.component.html',
styleUrls: ['./extrato.component.scss'],
})
export class ExtratoComponent implements OnInit {
@Input() transferencias: any[] = [];
constructor(private service: TransferenciaService) {}
ngOnInit(): void {
this.service.todas().subscribe((transferencias: Transferencias[]) => {
console.table(transferencias);
this.transferencias = transferencias;
});
}
}
Se eu deixar o código igual o do repositório do Github a aplicação sobe, porém, as propriedades do extrato deixam de funcionar.
import { TransferenciaService } from './../services/transferencia.service';
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-extrato',
templateUrl: './extrato.component.html',
styleUrls: ['./extrato.component.scss'],
})
export class ExtratoComponent implements OnInit {
@Input() transferencias: any[] = [];
constructor(private service: TransferenciaService) {}
ngOnInit(): void {
this.transferencias = this.service.transferencias;
this.service.todas().subscribe((x) => (this.transferencias = x));
}
}