Created
August 28, 2017 04:29
-
-
Save PauloCeami/60f30679079e97cbd66f0f314c84b196 to your computer and use it in GitHub Desktop.
trabalhar com lista de objetos fora do escopo subscribe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ClienteService } from './../clientes.service'; | |
import { ClienteModel } from './../cliente'; | |
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
@Component({ | |
selector: 'app-clientes-lista', | |
templateUrl: './clientes-lista.component.html', | |
styleUrls: ['./clientes-lista.component.css'], | |
}) | |
export class ClientesListaComponent implements OnInit { | |
clientes: any[]; | |
mClienteModelList: ClienteModel[]; | |
pagina: number = 0; | |
qtdPorPagina: number = 2; | |
total: number; | |
constructor( | |
private route: ActivatedRoute, | |
private mClientesService: ClienteService) { | |
} | |
ngOnInit() { | |
this.getAllClientes(); | |
} | |
paginar($event: any) { | |
this.pagina = $event - 1; | |
} | |
getAllClientes(){ | |
this.mClientesService.getClientesObservable() | |
.subscribe( | |
mCliente => { | |
// minha lista que preciso trabalhar | |
this.mClienteModelList = mCliente; | |
}, //Bind to view | |
err => { | |
// Log errors if any | |
console.log(err); | |
}) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment