Angular 4 ng-repeat implementation

怎甘沉沦 提交于 2019-12-01 08:08:07

问题


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>

回答1:


<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/



来源:https://stackoverflow.com/questions/45792817/angular-4-ng-repeat-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!