I have a lot of boilerplate code on my templates that follow roughly this structure.
<div class="form-group col-lg-6"
[ngClass]="{'has-error': errors?.startDate || !startDate.valid}">
<label>Start Date</label>
<input class="form-control"
[(ngModel)]="currentEntity.startDate"
#startDate="ngModel" name="startDate"
required />
<small *ngIf="!startDate.valid" class="help-block">
Start Date Is Required
</small>
<small *ngIf="errors?.startDate" class="help-block">
{{errors.startDate}}
</small>
</div>
The second error block is for any server validations that come back.
I was hoping to make a directive that could just be something like <validatedInput [inputName] = "startDate" /> and replace the key elements in each property. Is there anyway to dynamically change things like #startDate="ngModel" to #{{inputName}}="ngModel". ngIf would also have to be set up dynamically.
I'm running "@angular/forms": "0.1.1".