我刚刚开始学习角度4.这是一个简单的代码,我试图在Visual Studio代码中实现,但不断收到此错误.
Uncaught Error: Template parse errors:
Can't bind to 'ngForFor' since it isn't a known property of 'li'. ("
</ul>
<ul>
<li [ERROR ->]*ngFor="let hobby for hobbies">{{hobby}}</li>
</ul>"): ng:///AppModule/UserComponent.html@6:6
Property binding ngForFor not used by any directive on an embedded template.
Make sure that the property name is spelled correctly and all directives are
listed in the "@NgModule.declarations".("
</ul>
<ul>
[ERROR ->]<li *ngFor="let hobby for hobbies">{{hobby}}</li>
</ul>"): ng:///AppModule/UserComponent.html@6:2
Run Code Online (Sandbox Code Playgroud)
我尝试过将CommonModule添加到app.module文件的先前解决方案.但它还没有解决问题.我无法弄清楚出了什么问题.
app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'app-root', …Run Code Online (Sandbox Code Playgroud)