0

I have a template driven form which contains child component

<form>
   <child-comp [(model)]="model.Property" ngModel ngDefaultControl required></child-comp>
</form>

and child component also constains second child component:

<div class="row">
   <child-comp2 [(model)]="model.Property1" ngModel ngDefaultControl required></child-comp2>
   <input name="mobile" type="text" [(ngModel)]="model.Mobile" required>
</div>

child component 2

<div class="row">
  <input name="name" type="text" [(ngModel)]="model.name" required>
</div>

if i dont fill name input, on submit form valid is true, but when I enter it and then remove validation working and isvalid is false.

how can i validate hierarchy component inputs?

Thanks

ika_919
  • 11
  • 4
  • Here I would really suggest a reactive form. I have found that using template driven form with nested components is truly a headache so I have stopped even attempting to do that ;) With a reactive form it's really easy to handle nested (child) components. So I suggest you consider that :) – AT82 Jul 19 '17 at 09:03
  • Check this out: https://stackoverflow.com/questions/39242219/angular2-nested-template-driven-form – Martino Bordin Sep 04 '17 at 10:01

0 Answers0