Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't bind to 'ngforOf'(ngFor) since it isn't a known property of 'div'

When adding an ngFor to a div I get the following warning and it appears to be stopping my HTML from rendering.

I tried *ngFor on <li>, <tr>, <th>, <span>, <ng-template> and got the same error message. It works elsewhere but not here.(I don’t use it in <p-dialog> in other places)

If the problem is the missing module in app.component.ts, I couldn’t find which one is missing.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

my-page.component.html

<p-dialog [(visible)]="displayPopup"
          [style]="{minWidth: '716px', minHeight: '270px', height:'50%'}"
          [baseZIndex]="10000"
          [modal]="true"
          [responsive]="true"
          [maximizable]="true">
  <p-header>

    <div *ngfor="let model of models">
      {{model.name}} Update
    </div>
  </p-header>
  <div style="min-height:335px!important">
    <app-newComponent #newComp
                    [data1]="data1"
                    [data2]="data2"
                    (onChange)="onModelditChange($event)"></app-newComponent >
  </div>
  <p-footer>
    <button type="button" pButton icon="pi pi-times" (click)="updateModel()" label="Save"></button>
  </p-footer>
</p-dialog>

app.module.ts

@NgModule({
  imports: [
    BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
    ReactiveFormsModule,
    HttpClientModule,
    CommonModule,
    AuthModule.forRoot(),
    FormsModule,
    routing,
    AccordionModule,
    BrowserAnimationsModule,
    TreeTableModule,
    InputTextModule,
    InputTextareaModule,
    ButtonModule,
    CheckboxModule,
    DropdownModule,
    CalendarModule,
    ChipsModule,
    KeyFilterModule,
    InputSwitchModule,
    ListboxModule,
    InputMaskModule,
    RadioButtonModule,
    SpinnerModule,
    SelectButtonModule,
    ToggleButtonModule,
    PickListModule,
    TriStateCheckboxModule,
    TableModule,
    PickListModule,
    FieldsetModule,
    CheckboxModule,
    FieldsetModule,
    GalleriaModule,
    LightboxModule,
    ScrollPanelModule,
    PanelModule,
    SidebarModule,
    MatDialogModule,
    SidebarModule,
    DialogModule,
    DynamicDialogModule,
    DialogModule,
    NgbModule,
    ProgressSpinnerModule,
    ImageViewerModule,
    NgbModule,
    MultiSelectModule,
    MessagesModule,
    MessageModule,
    CurrencyMaskModule,
    FileUploadModule,
    ChartModule,
    ToastModule,
    EditorModule,
    TooltipModule,
    TabViewModule,
    ConfirmDialogModule,
    DragDropModule,
  ],
}

>Solution :

looks like you misspelled the structural directive.
it’s *ngFor, not *ngfor

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading