0

I'm currently trying to bind a form to my redux store following this( template driven)

so lets say i have the following structure:

{   
 person {
  personName: string,
  address {
   street: string,
   city: string
  }
 }
}

Now i want to bind this to a form:

<form [connect]=['person']>
 <input type="text" name="personName">
 <!-- now i want to show the street and city -->
 <input type="text" name="street">
 <input type="text" name="city">
</form>

How do i tell the form that i want to add address to the path so i can bind streetand cityto my store?

Community
  • 1
  • 1
kodeaben
  • 1,829
  • 3
  • 24
  • 33

1 Answers1

0

So i found the solution:

<form [connect]=['person']>
  <input type="text" name="personName">
  <!-- now i want to show the street and city -->
  <div [ngModelGroup]="'address'">
   <input type="text" name="street">
   <input type="text" name="city">
  </div>
</form>

I pass the address as a string to the modelGroup and this creates the necessary link in the path

kodeaben
  • 1,829
  • 3
  • 24
  • 33