【问题标题】:Ionic 2 - returns [object,object]离子 2 - 返回 [object,object]
【发布时间】:2017-05-06 04:24:25
【问题描述】:

这是我的数组推送:

let results = this.allExercises[i];
this.dataArray.push(results);

我给 navParams 一个这样的页面推送:

    this.navCtrl.push(HomePage, {
        'exercisesDone': this.dataArray
    });

我像这样在我的主页中检索它们:

constructor(public navCtrl: NavController, public params:NavParams) {
      if(params.get("exercisesDone")){
        this.exerciseIsDone = params.get("exercisesDone");
        console.log('exerciseDone: ', this.exerciseIsDone);
      }
  }

有了这个输出:

在我的 html 中,我这样做:

  <p>{{ exerciseIsDone }}</p>
  <div *ngFor="let b of exerciseIsDone; let i = index">{{ b }}</div>

以此为结果:

<p>[object Object], [object Object],[object Object]</p>
<div>[object Object]</div>
<div>[object Object]</div>

如何打印数组的值?

【问题讨论】:

  • {{b.exercise}}

标签: angular typescript ionic2


【解决方案1】:

您正在打印对象。应该是:

<div *ngFor="let b of exerciseIsDone; let i = index">{{b.done}}{{b.exercise}}{{b.path}}</div>

【讨论】:

  • 不打印任何东西
  • Ohh nvm 我首先必须选择它们-.-''
猜你喜欢
  • 1970-01-01
  • 2016-11-19
  • 2013-09-13
  • 2015-01-24
  • 1970-01-01
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 2015-07-16
相关资源
最近更新 更多