Mesmo usando o ? o Angular continua falhando ao compilar:
error TS2531: Object is possibly 'null'.
<small *ngIf="loginForm.get('userName').errors?.required"
class="text-danger d-block mt-2">
User name is required!
</small>
Mesmo usando o ? o Angular continua falhando ao compilar:
error TS2531: Object is possibly 'null'.
<small *ngIf="loginForm.get('userName').errors?.required"
class="text-danger d-block mt-2">
User name is required!
</small>
Se colocar o elvis operator
antes do .errors
não resolveria?
ex:
loginForm.get('userName')?.errors?.required
Sim! No meu resolveu:
loginForm.get('userName')?.errors?.required
npm 6.14 / angular 11.0.9