[英]Error: Template parse errors: Can't bind to 'ngForOf' since it isn't a known property of 'template'
I'm trying to use the HTML tag to build a table and got the error in the title. 我正在尝试使用HTML标记构建表并在标题中出现错误。
Here is the template: 这是模板:
<template ngfor let-log [ngForOf]="logs">
<tr>
<td [lgStatus]="log.level" class="ion-record"></td>
<td>{{log.timestamp | date:'medium'}}</td>
<td>{{log.source}}</td>
<td>{{log.message}}</td>
</tr>
<tr>
<td colSpan="4">{{log.detailedMessage}}</td>
</tr>
</template>
I checked several threads and I correctly imported the BrowserModule in the app.module.ts and the CommonModule in the component related to this template. 我检查了几个线程,并正确导入了app.module.ts中的BrowserModule和与此模板相关的组件中的CommonModule。
I don't see what I have done wrong here :( 我看不到我做错了什么:(
Thanks in advance for your help. 在此先感谢您的帮助。 Serge.
哔叽。
Exact syntax will be ngFor
not ngfor
so use your code like this- 确切的语法将是
ngFor
而不是ngfor
因此请使用以下代码-
<template ngFor let-log [ngForOf]="logs">
for more type you can refer here 欲了解更多类型,请点击这里
<template ngfor let-log [ngForOf]="logs">
has to be 必须
<template ngFor let-log [ngForOf]="logs">
^
You can use <ng-container>
instead of <template>
to be able to use the more common syntax 您可以使用
<ng-container>
而不是<template>
来使用更常见的语法
<ng-container *ngFor="let log of logs">
有一个小错字,
<template ngFor let-log [ngForOf]="logs">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.