How to pass array values from ts to html


#1

how to pass values from ts to html in constructor and display in html


#2

This is actually a (very) basic Angular2 question. Therefore I would very much suggest you to take the tour of heroes provided by the Angular team to get up and running. You can find it over here:

https://angular.io/docs/ts/latest/tutorial/


#3

check this code ts file

export class HomePage {
  public images=[];
  public imagesSrc = ["../../assets/images/01.jpg", "../../assets/images/02.jpg", "../../assets/images/03.jpg"];

grid: Array<Array<string>>; 

  constructor(public navCtrl: NavController,public navParams: NavParams) {
    for(let i=1;i<=this.imagesSrc.length;i++){
      this.images.push({"src":this.imagesSrc[i]});
    }
    this.imagesSrc=this.imagesSrc;
  }
}

html file

 <ion-row *ngFor="let row of grid" direction="x" style="height:200px; min-height: 200px;">
      <img ng-repeat="image in images" [(ngModel)]="images" src="{images.src}"/>
    </ion-row>

#4