Cannot read property 'disable' of undefined: this.ngControl.control is undefined in Ivy

Discussão em 'Angular' iniciado por ForestG, Outubro 23, 2024.

  1. ForestG

    ForestG Guest

    Just as this issue states, if you try to access an ngControl.control with a Directive:

    export class DisabledDirective {
    @Input()
    set opDisabled(condition: boolean) {
    const action = condition ? 'disable' : 'enable';
    this.ngControl.control[action]();
    }

    constructor(private ngControl: NgControl) {}
    }


    You will reach an error upon first rendering:

    core.js:5828 ERROR TypeError: Cannot read property 'disable' of undefined

    Continue reading...

Compartilhe esta Página