![](/img/trans.png)
[英]Can't bind to 'ngForOf' since it isn't a known property of 'div'. ngFor not displaying anything in the browser
[英]“Can't bind to 'ngFor' since it isn't a known native property”
在這里不知道我在做什么錯。 嘗試通過CORE_DIRECTIVES並使用let明確定義ngFor指令。 有什么我想念的嗎?
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上獲取錯誤
<ul >
<li *ngFor="let thing of list">
<p>{{thing}}</p>
</li>
</ul>
去掉
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES]
使用#
而不是let
您顯然正在使用的Angular2 beta中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.