user1785868
user1785868

Reputation: 54

angular-formly data binding between repeating sections

I'm attempting to make a dynamic form that uses live data from other fields in a cascade from max_points to 0.

Each row has a high and low range, and the high range of the next form is always the low_range of the previous-1.

I'm having trouble with how to manipulate the model data in a field setting. Moreover, I'm a little confused about how to access the larger data model on the scope of each field:

{
   type: 'input',
   //want to bind this field to the previous index's low_range -1  
   key: 'high_range',
   className: 'col-xs-4',
   templateOptions: {
     label: 'High Range',
     disabled: true 
   }
   controller: function($scope) {
      //I have access to the element this corresponds to, but haven't found a way to lookup this element in the larger model array
   }
}

Ideally the high range of the first element would be max_points, then each one after would reference the previous low_range

here is my live example: http://jsbin.com/behosokoye/edit

Upvotes: 0

Views: 827

Answers (1)

kentcdodds
kentcdodds

Reputation: 29051

Does this do what you're looking for? I'm not sure what trouble you were having, but I think this does what you want: http://jsbin.com/lidezi/edit?js,console,output

Upvotes: 0

Related Questions