I have a lot of form-groups with labels and inputs.I wanted to make ng-template which will be reusable
So i had
<div class="form-group">
<label class="form-control-label" for="address">Address</label>
<input [disabled]="isTheLoggedInUserAdmin" id="address" class="form-control form-
control-alternative"
[(ngModel)]="sharedService.tempUser.address" name="address" type="text">
</div>
and with ng-template it is converted to
<ng-template [ngTemplateOutlet]="formGroup"
[ngTemplateOutletContext]="{data: {inputId:'address', label:'Address', ngModel:
sharedService.tempUser.address }}"
></ng-template>
<ng-template #formGroup let-data="data">
<div class="form-group">
<label class="form-control-label" [for]="data.inputId">{{data.label}}</label>
<input [disabled]="isTheLoggedInUserAdmin" [id]="data.inputId" class="form-control form-control-
alternative"
[(ngModel)]="sharedService.tempUser.address" [name]="data.inputId" type="text">
</div>
</ng-template>
so i am passing here inputId, label name automatically and for now the ngModel is hardcoded it is pointing to sharedService.tempUser.address
But my ng-template needs to be dynamic so with ng-template call i should pass argument like label for example
- tthe argument shpuld point to different ngModel variables in my typescript files
But when i do that
<div class="form-group">
<label class="form-control-label" [for]="data.inputId">{{data.label}}</label>
<input [disabled]="isTheLoggedInUserAdmin" [id]="data.inputId" class="form-control form-control-alternative"
[(ngModel)]="data.ngModel" [name]="data.inputId" type="text">
</div>
now data.ngModel
is sended from the ng-template call - which is sharedService.tempUser.address
, i get the actual value from sharedService.tempUser.address
but *THE PROBLEM IS THAT ngModel does not work here`
when i type something it is not updated
How can i solve this ?