ERROR TypeError: Cannot read properties of null (reading 'offsetHeight') in primeng MenuModule

Discussão em 'Angular' iniciado por davood beheshti, Abril 28, 2025.

  1. I am using MenuModule primeng

    The model inside Menu is of type signal

    And it is taken from service

    Now when service is called and model is filled this error is displayed

    ERROR TypeError: Cannot read properties of null (reading 'offsetHeight')


    //Html Code

    <h1 (click)="statusDispacherClick(213 , $event)">
    Status Click
    </h1>
    <p-menu #menu [model]="listStatusTypes()" [popup]="true" />


    //typeScript Code

    @ViewChild('menu') menu !: Menu;
    listStatusTypes = signal<any[]>([])

    statusDispacherClick(data, event) {
    this.service.getDashboardChangeStatusTypes(data).subscribe(dataService => {
    dataService.map(x => {
    x.label = x.title;
    })
    this.listStatusTypes.set(dataService);
    this.cdRef.detectChanges();
    this.menu.toggle(event);
    })
    }

    Continue reading...

Compartilhe esta Página