I have a form
<form #basic="ngForm"> <div> <label>Firstname:</label> <input type="text" name="firstName" ngModel required> </div> <div> <label>Lastname:</label> <input type="text" name="lastName" ngModel> </div> <address ></address> </form> and in that form there is a child component <address> and I want validation on parent and child component both. I want to do it with ngForm, I know how to do it with formgroups, by passing form variable into child component but I have tried that as well but it get me an error
child component
import { Component, Input } from '@angular/core'; @Component({ selector: 'address', template: ` <div> <label>Zip:</label> <input [ngClass]="{error: (basic.submitted)}" type="text" name="zip" ngModel> </div> <div> <label>Street:</label> <input type="text" name="street" ngModel required> </div> <div> <label>City:</label> <input type="text" name="city" ngModel> </div> `, }) export class AddressComponent { }