Tenho uma classe onde preciso atribuir a uma variável do tipo array para passar para a view. Só que na saída fala que a variável não está definida. Segue meu código:
`import { Component } from '@angular/core';
import { NavController, NavParams } from ‘ionic-angular’;
import { Geolocation } from ‘@ionic-native/geolocation’;
import { LojasProvider } from ‘./…/…/providers/lojas/lojas’;
/**
- Generated class for the ModalviewPage page.
- See https://ionicframework.com/docs/components/#navigation for more info on
- Ionic pages and navigation.
*/
declare var google;
@Component({
selector: ‘page-modalview’,
templateUrl: ‘modalview.html’,
providers: [LojasProvider]
})
export class ModalviewPage {
map: any;
//public lojaModelo: Loja;
lojas: Array<{ nome: string, descricao: any, tipo: string, img: string, latitude: string, longitude: string, cidade: string }>;
constructor(public navCtrl: NavController, public navParams: NavParams, public lojasProvider: LojasProvider,
private geolocation: Geolocation) {
this.geolocation.getCurrentPosition()
.then((resp) => {
const position = new google.maps.LatLng(resp.coords.latitude, resp.coords.longitude);
const mapOptions = {
zoom: 18,
center: position
}
this.map = new google.maps.Map(document.getElementById('map'), mapOptions);
const marker = new google.maps.Marker({
position: position,
map: this.map
});
// Insere os que estão cadastrados na região
// Pega de uma Promise
this.lojasProvider.busca().then(function(value) {
this.lojas = value;
console.log(value);
}, function(value) {
});
}).catch((error) => {
console.log('Erro ao recuperar sua posição', error);
});
}
ionViewDidLoad() {
}
}Ja testei no console e está retornando o json normalmente, só que preciso botar nessa variável ai. Segue meu html:
<!–
Generated template for the ModalviewPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
–>

<ion-list>
<ion-item *ngFor="let p of lojas" text-wrap>
<ion-col col-6 style="background-color: white; opacity: 0.5; margin-left: 3%;">
<img src="http://easyrowbr.com.br/img/marker.png" width="40" height="40">
</ion-col>
<ion-col col-6 style="background-color: white; opacity: 0.5; margin-left: 3%;">
{{p.nome}}
</ion-col>
</ion-item>
</ion-list>
</ion-row>
</ion-grid>
</div>
`
Qualquer ajuda será bem vinda.