无法绑定到'NG-forOf',因为它不是一个已知的原生属性 [英] Can't bind to 'ng-forOf' since it isn't a known native property
问题描述
我想在这里遵循的基本角2教程:
I am trying to follow the basic Angular 2 tutorial here:
<一个href=\"https://angular.io/docs/js/latest/guide/displaying-data.html\">https://angular.io/docs/js/latest/guide/displaying-data.html
I can get the angular app to load and display my name with this code:
然而,当我尝试添加一个字符串数组,并尝试用NG-用于显示它们,它抛出以下错误:
However when I try to add an array of strings and try to display them with an ng-for, it is throwing the following error:
Can't bind to 'ng-forOf' since it isn't a known native property ("
<p>Friends:</p>
<ul>
<li [ERROR ->]*ng-for="#name of names">
{{ name }}
</li>
"): AppComponent@4:16
Property binding ng-forOf not used by any directive on an embedded template ("
<p>Friends:</p>
<ul>
[ERROR ->]<li *ng-for="#name of names">
{{ name }}
</li>
"): AppComponent@4:12
下面是code:
我是什么失踪?
推荐答案
如果您使用阿尔法52,检查出的 CHANGELOG.md 在GitHub的回购。他们改变了模板区分大小写是 ngFor
而不是 NG-对
(类似于所有其他指令)
If you use alpha 52, check out the CHANGELOG.md in the GitHub repo. They changed the template to case-sensitive which is ngFor
instead of ng-for
(similar for all other directives)
元素的名称,如&LT;路由器的出口方式&gt;
没有改变,虽然留在自定义元素兼容测试,这需要自定义元素的标签名破折号
Element names like <router-outlet>
weren't changed though to stay compatible with custom elements spec which requires a dash in the tag name of custom elements.
这篇关于无法绑定到'NG-forOf',因为它不是一个已知的原生属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!