NgZorro Modal - How to pass data into the modal in Angular 16?

Discussão em 'Angular' iniciado por Tony Brasunas, Dezembro 4, 2024.

  1. I'm using Ant Design for Angular library ng-zorro-antd.

    This was working on Angular 12, but now after upgrading to Angular 16, I'm seeing this error: ERROR TypeError: Cannot read properties of undefined (reading 'name')

    I create the modal like this:

    private _createDeleteModal(vehicleGroupDetails: VehicleGroupDetails) {
    this.modalService
    .create({
    nzTitle: 'Delete Vehicle Group',
    nzContent: VehicleGroupDeleteComponent,
    nzComponentParams: { existingVehicleGroup: vehicleGroupDetails },
    })



    And in the modal component I would get the params data like this:


    export class VehicleGroupDeleteComponent implements OnInit {
    @Input() existingVehicleGroup: VehicleGroupDetails;
    ...
    this.vehicleGroupForm = new FormGroup({
    name: new FormControl(this.existingVehicleGroup?.name ?? '', [
    Validators.required,...



    But now it seems the data isn't there at all and I just see the above error repeating over and over, crashing the browser.

    Continue reading...

Compartilhe esta Página