Can't bind to 'ngForOf' since it isn't a known property of 'tr' (final release)

后端 未结 22 1796
谎友^
谎友^ 2020-11-27 14:37

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          


        
相关标签:
22条回答
  • 2020-11-27 15:06

    For Angular 10:

    1. Add BrowserModule to the imports of your routes module.
    2. Make sure that you added the component that not working to the app module declarations.

    Failing to do step 2 will trigger this error!

    Make sure to RESTART ng serve !!!

    0 讨论(0)
  • 2020-11-27 15:07

    Future Readers

    Check each of the following:

    1. The component is declared in a SINGLE angular module
    2. Make sure you have import { CommonModule } from '@angular/common';
    3. Restart the IDE/editor
    4. Restart the dev server (ng serve)
    0 讨论(0)
  • 2020-11-27 15:07

    I had the same error but I had the CommonModule imported. Instead I left a comma where it shouldn't be because of copy/paste when splitting a module:

    @NgModule({
        declarations: [
            ShopComponent,
            ShoppingEditComponent
        ],
        imports: [
            CommonModule,
            FormsModule,
            RouterModule.forChild([
                { path: 'shop', component: ShopComponent }, <--- offensive comma
            ])
        ]
    })
    
    0 讨论(0)
  • 2020-11-27 15:12

    In my case, the issue was that my teammate mentioned *ngfor in templates instead of *ngFor. Strange that there is no correct error to handle this issue (In Angular 4).

    0 讨论(0)
提交回复
热议问题