I\'m using Angular2 Final release (2.1.0). When I want to display a list of companies, I got this error.
in file.component.ts :
public
A lot of answers seem to converge by importing CommonModule in other(new/custom) modules.
This step only isn't enough in all situations.
The full solution consist in two steps:
NgIf, NgFor etc visible to your project.app.module.ts)Point 1
BrowserModule in main module seems to be enough for having access to NgFor.
Angular Documentation stands it here: .
CommonModule Exports all the basic Angular directives and pipes, such as NgIf, NgForOf, DecimalPipe, and so on. Re-exported by BrowserModule,
See also accepted answer here: CommonModule vs BrowserModule in angular
Point 2
The only changes needed (in my case) are the followings:
OtherModuleOtherComponentapp.module.ts
@NgModule({
imports: [
BrowserModule,
OtherModule
],
declarations: [OtherComponent, AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
other.html
other.component.ts
@Component({
selector: 'other-component',
templateUrl: './other.html'
})
export class OtherComponent {
}
app.module.ts
@NgModule({
imports: [],
providers: []
})
export class OtherModule{
}