Angular 4 ng-repeat实施 [英] Angular 4 ng-repeat implementation
本文介绍了Angular 4 ng-repeat实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Angular 4为Ionic 3项目实现一个非常基本的ng-repeat指令.我只是不明白为什么这段代码不能返回任何东西.我想大量的Ionic和Angular文档都让我感到困惑. 有什么主意吗?
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>
推荐答案
<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>
工作代码为 https://gitlab.com/ugur.ayan/temp-ionic/
这篇关于Angular 4 ng-repeat实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文