Sireini
Sireini

Reputation: 4262

Ionic 2 - returns [object,object]

This is my array push:

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

I give navParams with a page push like this:

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

I retrieve them in my HomePage like this:

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

With this output: enter image description here

And in my html I do this:

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

With this as outcome:

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

How can i print the values of the array?

Upvotes: 0

Views: 2169

Answers (1)

wannadream
wannadream

Reputation: 1760

You are printing object. It should be:

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

Upvotes: 1

Related Questions