Why it's still possible to assing null for nonNullable FormControl

Discussão em 'Angular' iniciado por s-f, Março 3, 2025.

  1. s-f

    s-f Guest

    This simple code returns me null, I had expectations that nonNullable form would have some checks inside. Do you have any idea why it's implemented like this?

    I tested it with Angular 18

    test = new FormControl('', { nonNullable: true });
    ...
    const val: any = null;
    this.test.setValue(val);
    console.log(this.test.value); // returns null

    Continue reading...

Compartilhe esta Página