Skip to content

Instantly share code, notes, and snippets.

@PauloCeami
Created August 28, 2017 04:29
Show Gist options
  • Save PauloCeami/60f30679079e97cbd66f0f314c84b196 to your computer and use it in GitHub Desktop.
Save PauloCeami/60f30679079e97cbd66f0f314c84b196 to your computer and use it in GitHub Desktop.
trabalhar com lista de objetos fora do escopo subscribe
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