Bertrand Bertrand - 2 months ago 15
TypeScript Question

Angular 4 ng-repeat implementation

I'm trying to implement a very basic ng-repeat directive for a Ionic 3 project using Angular 4. I simply don't understand why this code is not returnig anything. I guess the numerous of the Ionic and Angular documentation are confusing me....
Any idea?

home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

public item = {} ;
public itemsList = [
{"name":"Mark", "position":"CEO"},
{"name":"David", "position":"Developer"}
];

constructor(public navCtrl: NavController) {

}

}


home.html

<ion-content padding>
<ion-list>
<ion-item ng-repeat="item of itemsList">
<h3> name: {{item.name}}</h3>
<p> position: {{item.position}}</p>
</ion-item>
</ion-list>
</ion-content>

Answer Source
<ion-content padding>
    <ion-list>
      <ion-item *ngFor="let item of itemsList">
        <h3> name: {{item.name}}</h3>
        <h3> name: {{item.position}}</h3>
      </ion-item>
    </ion-list>
</ion-content>

Working code is https://gitlab.com/ugur.ayan/temp-ionic/