[formControlName] not working

I’m using Angular8 with Ionic 4. I create dynamic reactive forms. In a loop I have the following code

<ng-container *ngIf="type === 'input'">
    <ion-input [fromControlName]="property.formPropertyName"></ion-input>

And this error:

compiler.js:2420 Uncaught Error: Template parse errors:
Can’t bind to ‘fromControlName’ since it isn’t a known property of ‘ion-input’.

  1. If ‘ion-input’ is an Angular component and it has ‘’ input, then verify that it is part of this module.

If I remove the brackets
<ion-input class="title standardTitleLabel" fromControlName="property.formPropertyName"></ion-input>

the code works fine

Why is that so?

Because when you put it in brackets, the Angular compiler says to itself “I need to find a property with that name in the controller”, and when it doesn’t find one, it gets cranky. When you take the brackets off, the Angular compiler DGAF any more about the fact that you spelled “form” as “from”.

1 Like