在离子应用

时间:2018-03-08 10:34:58

标签: javascript html ionic-framework

我成功地将网络服务与应用程序相关联,并检索了数据,但我无法访问数据以显示它或在任何过程中使用它。



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检索的结果是:

enter image description here

我正在使用此代码在离子元素中显示数据。



<ion-list>
    <button ion-item *ngFor="let user of (usercheck|async)?.Array" (click)="openDetails(user)">
      {{ user.CinemaName }}
    </button>
  
  </ion-list>
&#13;
&#13;
&#13;

但没有结果

提前感谢。

1 个答案:

答案 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>