【发布时间】:2020-06-13 19:16:36
【问题描述】:
问题:我的 ngfor 在运行网络时运行良好,但是当我在真实设备上模拟我的应用程序时,它就无法正常工作。我看遍了 互联网上的解决方案,但找不到,就像一个接近的一样(多数民众赞成在 我怎么想),有人说这是 ngZone 问题,我没有 知道它是什么。
我的服务
getMenuObject(): Observable<any> {
return this.http
.post("xxxxxxx.xxxxxxxxx.xxxxxxxxx.xxxxxxxxxxx",{ HotelId:25, GroupId:9 });
}
我的 .ts
data: Array<any>=[]
ngOnInit(){
this.httpService.getMenuObject().toPromise().then(x=>{
this.data = x;
console.log(this.data)
if(x.IsGroup==true){
this.splashScreen.hide();
} else{
this.router.navigate(['folder/Inbox']);
}
});
}
我的html:
<ion-card *ngFor="let otel of data.MobileHotelDefinitions" style="margin: 40px 0;border-radius: 0;">
<ion-card-header style="padding: 0;">
<ion-img (click)="goToHotel()" [src]="otel.MobileApplicationDefinition.GroupImageUrl"></ion-img>
<div class="otelName">
<div style="flex: 1;">{{otel.Name}}</div>
<div style="color: goldenrod;">★★★★★</div>
</div>
</ion-card-header>
<ion-card-content>
Keep close to Nature's heart... and break clear away, once in awhile,
and climb a mountain or spend a week in the woods. Wash your spirit clean.
</ion-card-content>
</ion-card>
我在网络浏览器上的应用(ionic serve --o):
【问题讨论】:
-
尝试用 NgZone 封装你的代码并检查。
标签: android angular ionic-framework ngfor