用于产生误差的角度2指令的Dart实现
在Angular 2 Beta 0的Dart实现中尝试使用ngFor指令时,会生成以下编译时错误用于产生误差的角度2指令的Dart实现,dart,angular,angular-dart,Dart,Angular,Angular Dart,在Angular 2 Beta 0的Dart实现中尝试使用ngFor指令时,会生成以下编译时错误 Property binding ngForOf not used by any directive on an embedded template ("[ERROR ->] <div *ngFor="#item of items"> {{item}} </div>"): 属性绑定ngForOf未被嵌入模板上的任何指令使用(“[ERROR->] {{item}} "
Property binding ngForOf not used by any directive on an embedded template ("[ERROR ->]
<div *ngFor="#item of items">
{{item}}
</div>"):
属性绑定ngForOf未被嵌入模板上的任何指令使用(“[ERROR->]
{{item}}
"):
组成部分:
库设计;
进口“包装:angular2/angular2.dart”;
@组成部分(
选择器:“设计组件”,
templateUrl:'design.html',
viewProviders:const[核心指令]
)
类设计组件{
清单项目=[“一”、“二”、“三”];
}
模板:
{{item}}
如果您有任何建议或帮助,我们将不胜感激。
viewProviders
应该是指令
<代码>视图提供程序用于依赖项注入 对我有用的东西正在改变:
<li *ng-for="#name of friendNames">
致:
在我的模板中
以下是我的组件:
@Component(selector: "app",
directives: const [NgFor],
templateUrl: 'app_component.html')
class AppComponent{
List<String> friendNames = const ["a", "b", "c"];
}
@组件(选择器:“应用程序”,
指令:const[NgFor],
templateUrl:'app_component.html')
类AppComponent{
List friendNames=const[“a”、“b”、“c”];
}
Gunther Zochbauer在其回答的评论中提到了这一点。我在尝试与
Angular 2 Beta
一起使用时仍会遇到相同的错误<代码>属性绑定forOf未被嵌入模板上的任何指令使用()实际上它对我有效。我只是错过了在示例应用程序的模板中有另一个ng for
。在我将其更改为ngFor
之后,所有操作都正常。
<li *ng-for="#name of friendNames">
<li *ngFor="#name of friendNames">
@Component(selector: "app",
directives: const [NgFor],
templateUrl: 'app_component.html')
class AppComponent{
List<String> friendNames = const ["a", "b", "c"];
}