我想实现一个基本的购物清单,但我的ngFor Angular无法正常工作。Angular2 ngFor不工作
import { Component, View } from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>{{title}}</h1><ul><li *ngFor="let i of items"><span>{{i}}</span></li></ul>'
})
export default class MyAppComponent {
title = 'ShoppinList';
items = ['Milk','Ham','Eggs'];
}
出现是唯一 “载入中...”,我得到超过10个神秘的错误。
您的组件应该包含'模板'和@'View'可以被删除。你的'import'语句不正确。也许你是从一个旧的测试版本复制/粘贴? – Igor