The following code snippet shows how I use array push:
let results = this.allExercises[i];
this.dataArray.push(results);
To pass data with navParams and navigate to a new page, I do the following:
this.navCtrl.push(HomePage, {
'exercisesDone': this.dataArray
});
In my HomePage component, I retrieve the passed data like this:
constructor(public navCtrl: NavController, public params:NavParams) {
if(params.get("exercisesDone")){
this.exerciseIsDone = params.get("exercisesDone");
console.log('exerciseDone: ', this.exerciseIsDone);
}
}
Here is the output: https://i.sstatic.net/Qd8FL.png
And in my HTML template file, I display the values like this:
<p>{{ exerciseIsDone }}</p>
<div *ngFor="let b of exerciseIsDone; let i = index">{{ b }}</div>
The current outcome looks like this:
<p>[object Object], [object Object],[object Object]</p>
<div>[object Object]</div>
<div>[object Object]</div>
How can I properly print the values stored in the array?