menu

Questions & Answers

Angular Data binding repeated

I created a form. then i added a link to add a section like previous. image1
when clicked add another address, it displayed address 2 form. image2
then i clicked the first input field, the validations errors are displayed in 2nd form also. image3

how to fix this? app.component.html

<label for="line1">STREET 1</label>
   <input id="line1" type="text" formControlName="line1" required/>
   <error-component
      [control]="formAddress.controls.line1">
   </error-component>

app.component.ts

formAddress = this.formBuilder.group({
    line1: ["", Validators.required],
    line2: '',
    postalCode: ["", Validators.required],
  });
Comments:
2023-01-25 07:42:02
Can you create a demo on StackBlitz? Want to know the implementation for adding the new address line.Thanks.
Answers(0) :