简体   繁体   English

错误:模板解析错误:无法绑定到“ ngForOf”,因为它不是“模板”的已知属性

[英]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.

相关问题 未捕获错误:模板解析错误:无法绑定到&#39;ngModel&#39;,因为它不是&#39;input&#39;的已知属性 - Uncaught Error: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input' 未捕获(承诺):错误:模板解析错误:由于它不是“输入”的已知属性,因此无法绑定到“上载器” - Uncaught (in promise): Error: Template parse errors: Can't bind to 'uploader' since it isn't a known property of 'input' 未捕获的错误:模板解析错误:无法绑定到“ FormGroup”,因为它不是“ form”的已知属性 - Uncaught Error: Template parse errors: Can't bind to 'FormGroup' since it isn't a known property of 'form' 错误:模板解析错误:无法绑定到“选项”,因为它不是“图表”的已知属性 - Error: Template parse errors: Can't bind to 'options' since it isn't a known property of 'chart' Angular中的错误:模板解析错误:无法绑定到&#39;datetime&#39;,因为它不是&#39;time&#39;的已知属性 - Error in Angular: Template parse errors: Can't bind to 'datetime' since it isn't a known property of 'time' 错误:模板解析错误:无法绑定到“评级”,因为它不是“评级”的已知属性 - Error: Template parse errors: Can't bind to 'rating' since it isn't a known property of 'rating' 错误:模板解析错误:无法绑定到“myProperty”,因为它不是“myComponent”的已知属性 - Error: Template parse errors: Can't bind to 'myProperty' since it isn't a known property of 'myComponent' 许多失败:模板解析错误:无法绑定到“routerLink”,因为它不是“a”的已知属性。 Karma 中的错误 - Lots of Failed: Template parse errors: Can't bind to 'routerLink' since it isn't a known property of 'a'. errors in Karma Angular 2:模板解析错误:无法绑定到&#39;ngModel&#39;,因为它不是&#39;input&#39;的已知属性 - Angular 2: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input' 模板解析错误:无法绑定到'ngbTypeahead',因为它不是'input的已知属性 - Template parse errors: Can't bind to 'ngbTypeahead' since it isn't a known property of 'input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM