【发布时间】:2018-11-09 00:27:35
【问题描述】:
在将 cli 升级到 v6 后,我刚刚创建了一个新项目,并使用 Angular Material 实用程序添加了仪表板布局。
我只是在胡闹,然后意识到 ngFor 不适合我。
我确保 CommonModule 正在被导入,我检查了其他指令是否像 *ngIf 一样工作。是我做错了什么还是更新后有问题?
测试组件:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit {
topics: ['C','C#']
constructor() { }
ngOnInit() {
}
}
HTML:
<div>
<p>Topics</p>
<ul>
<li *ngFor="let topic of topics">{{topic}}</li>
</ul>
</div>
我刚刚将我的 app-test 组件放在由仪表板快速入门构建的卡片中,这是呈现的内容。
【问题讨论】:
-
你有那个 li 的 css 吗?还是没有css?
-
没有 css 它创建了 css 文件,但我没有对其应用任何东西
-
你的控制台有输出吗?就像我的意思是一个错误..
-
不,这是令人困惑的部分,chrome 调试器中没有错误。
-
topics: ['C','C#']->:应该是=