LucasBrazi06
LucasBrazi06

Reputation: 127

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.

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.

I don't see what I have done wrong here :(

Thanks in advance for your help. Serge.

Upvotes: 0

Views: 2007

Answers (3)

Pardeep Jain
Pardeep Jain

Reputation: 86800

Exact syntax will be ngFor not ngfor so use your code like this-

<template ngFor let-log [ngForOf]="logs">

for more type you can refer here

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222722

There is a small typo,

<template ngFor let-log [ngForOf]="logs">

Upvotes: 0

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 658057

<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 *ngFor="let log of logs">

Upvotes: 0

Related Questions