I am new to working with angular and I was reading through the documentation but I could not find the proper way to declare some kind of variable that can be reused in nested html elements.
As a work around I did something that works but I consider a bit dirty. I would like to know how a proper solution for this would look like.
Basically, what I have is the identifier 'someProperty' that I want to use in many places in the nested HTML elements. I may want to use it as the formControlName but also as an argument to function calls. Right now I abuse the *ngFor for this purpose to define variable 'x'.
<div class="container-row" *ngFor="let x of ['someProperty']">
  <span *ngIf="isReadOnly(x)" class="readonly-indicator"></span>
  <span *ngIf="!isReadOnly(x)" class="writable-indicator"></span>
  <mat-form-field>
    <input matInput type="number" formControlName="{{x}}"
           [readonly]="isReadOnly(x)"
           (change)="onChange($event, x)"
           placeholder="This is some Property!">
    <mat-error *ngIf="!someFormGroup.controls[x].valid">ERROR!</mat-error>
  </mat-form-field>
</div>
 
     
    