Issue
I'm using Angular2 2.1.0. When I want to display a list of companies, I got this error.
in file.component.ts :
public companies: any[] = [
{ "id": 0, "name": "Available" },
{ "id": 1, "name": "Ready" },
{ "id": 2, "name": "Started" }
];
In file.component.html :
<tbody>
<tr *ngFor="let item of companies; let i =index">
<td>{{i}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
Solution
Add BrowserModule to imports: [] in @NgModule() if it's the root module (AppModule), otherwise the CommonModule.
// older Angular versions
// import {BrowserModule, CommonModule} from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'
..
..
@NgModule({
imports: [BrowserModule, /* or CommonModule */],
..
})
Answered By - Günter Zöchbauer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.