“无法绑定到'ngFor',因为它不是已知的本机属性" [英] "Can't bind to 'ngFor' since it isn't a known native property"
本文介绍了“无法绑定到'ngFor',因为它不是已知的本机属性"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这里不知道我在做什么错.尝试通过CORE_DIRECTIVES并使用let明确定义ngFor指令.有什么我想念的吗?
Can't tell what I'm doing wrong here. Tried explicity defining the ngFor directive through CORE_DIRECTIVES, and using let. Is there something I missed?
import { Component, Input , Output , EventEmitter} from 'angular2/core';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common';
@Component({
selector: 'panel',
moduleId: module.id,
templateUrl: './panel.component.html',
styleUrls: ['./panel.component.css'],
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES]
})
export class panelComponent {
list: String[];
}
在所有ngFors上获取错误
Getting an error on all ngFors
<ul >
<li *ngFor="let thing of list">
<p>{{thing}}</p>
</li>
</ul>
推荐答案
删除
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES]
使用#
代替您显然正在使用的Angular2 beta中的 let
.
use #
instead of let
in Angular2 beta that you're obviously using.
这篇关于“无法绑定到'ngFor',因为它不是已知的本机属性"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文