我成功地将网络服务与应用程序相关联,并检索了数据,但我无法访问数据以显示它或在任何过程中使用它。
constructor(public navCtrl: NavController, public navParams: NavParams, public apiProvider: ApiProvider, public alertCtrl: AlertController) {
this.usercheck = this.apiProvider.UserCheck();
this.usercheck.subscribe(data => {console.log('my data: ', data); });

console.log检索的结果是:
我正在使用此代码在离子元素中显示数据。
<ion-list>
<button ion-item *ngFor="let user of (usercheck|async)?.Array" (click)="openDetails(user)">
{{ user.CinemaName }}
</button>
</ion-list>
&#13;
但没有结果
提前感谢。
答案 0 :(得分:0)
您需要替换以下代码
constructor(public navCtrl: NavController, public navParams: NavParams, public apiProvider: ApiProvider, public alertCtrl: AlertController) {
this.usercheck = this.apiProvider.UserCheck();
this.usercheck.subscribe(data => {console.log('my data: ', data); });
到
testData: any = [];
constructor(public navCtrl: NavController, public navParams: NavParams, public apiProvider: ApiProvider, public alertCtrl: AlertController) {
this.usercheck = this.apiProvider.UserCheck();
this.usercheck.subscribe(data => this.testData = data;);
并替换以下代码
<ion-list>
<button ion-item *ngFor="let user of (usercheck|async)?.Array" (click)="openDetails(user)">
{{ user.CinemaName }}
</button>
</ion-list>
到
<ion-list>
<button ion-item *ngFor="let user of testData" (click)="openDetails(user)">
{{ user.CinemaName }}
</button>
</ion-list>