Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
Angular 2 Variable no definida - Ionic

tengo esto en mi html

 <ion-col col-3 align="right"> <ion-item> <ion-label>Show as</ion-label> <ion-select [ngModel]="SelectedView" (ngModelChange)="onViewChange($event)> <ion-option value="List">List</ion-option> <ion-option value="Map">Map</ion-option> </ion-select> </ion-item> </ion-col>

y esto en mi archivo customer.ts

 export class customerpage implements OnInit { constructor(public modalCtrl: ModalController, public popoverCtrl: PopoverController, private _customerservice: CustomersService, public navCtrl: NavController, public navParams: NavParams) { this.ListPositions = []; this.customersArray = []; this.customersView = []; } ngOnInit() { this.SelectedCategory = ""; this.customersArray = []; this.customersView = []; setTimeout(() => { this.GetCustomers(); }, 500); } GetCustomers() { const arrayofroles$ = this._customerservice.GetAllCustomers(); arrayofroles$.subscribe(res => { this.customersArray = res; //Initially both arrays are the same this.customersView = this.customersArray; }, err => { }, () => { this.loadingCustomers = false; }); } ionViewDidLoad(): void { } onViewChange(event: any, Customers: any) { this.initMap(Customers); } initMap(Customers: any) { this.customersView; // UNDEFINED! } }

Inicialmente, en nginit, estoy cargando la vista de clientes desde la base de datos. OnViewchange desde el html Estoy llamando a la función initmap e intentando acceder a cutomersview pero me está dando indefinido para mi variable local.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Una solución podría ser: parece que tiene un problema de sincronización de datos.

 // return subscription from this method getCustomers() { const customerSubscription = this._customerservice.GetAllCustomers(); return customerSubscription; } onViewChange(event: any) { this.getCustomers() .subscribe((customers: any) => { this.initMap(customers); }); }
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda