我的简化目标是构建一个组件,它是一个带有项目模板的列表.例如.:
<list>项目</list>
这是我的代码:
import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core';
@Component({
selector: 'list',
template: `
<ul>
<li *ngFor="let i of 项目s" >
<ng-content></ng-content>
</li>
</ul>
`
})
class List {
项目s = [1, 2, 3];
}
@Component({
selector: 'app',
directives: [List],
template: '<list>项目</list>'
})
class App { }
bootstrap(App, []);
预期结果:
- 项目
- 项目
- 项目
实际结果:
•