2017-04-05 33 views
0

我試圖使用HTML標記來構建表格並在標題中出現錯誤。錯誤:模板解析錯誤:無法綁定到'ngForOf',因爲它不是'模板'的已知屬性

這裏是模板:

<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> 

我檢查了幾個線程和我正確導入在app.module.ts的BrowserModule和與此相關的模板組件CommonModule。

我不明白我做了什麼錯在這裏:(

在此先感謝您的幫助。 嗶嘰。

回答

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

必須

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

你可以使用<ng-container>而不是<template>能夠使用更常見的語法

<ng-container *ngFor="let log of logs"> 
0

有一個小錯字,

<template ngFor let-log [ngForOf]="logs"> 
相關問題