I have a generic component like below,
// selector: 'app-text-box'
<form>
<input type="text"
[name]="data.name"
[id]="data.name"/>
</form>
<error-message [message]="message"></error-message>
Also my app component like below,
<div *ngFor="let data of jsonData | async">
<app-text-box [data]="data"
*ngIf="data.type === 'TEXT'">
</app-text-box>
</div>
And then my json
[
{
"type": "TEXT",
"name": "book"
},
{
"type": "TEXT",
"name": "note"
}
]
based on the above json, the app component will iterate it and render the input box, if I want to validate the both input field and then display error for corresponding input field. I don't know how to handle it using form?
ngOnInit()not inconstructor. I have just given you the design flow. Its not a complete code. You can definitely work it out