Here is my not working demo
<section ng-repeat="t in test">
<div ng-repeat="(key,value) in t">
<div>{{key}}</div>
<input type="text" ng-model="value"/>
</div>
</section>
Model stays the same. How to sync? Please note, structure of data is important.
Each iteration of ng-repeat creates a new child scope, and that new child scope always gets a new property.
Note: The $index variable is used to get the Index of the Row created by ng-repeat directive. Each row of the HTML Table consists of a Button which has been assigned ng-click directive. The $index variable is passed as parameter to the GetRowIndex function.
You can consider using transclusion inside a custom directive, to achieve the behavior you are looking for without using ng-repeat.
You can use $last variable within ng-repeat directive. Take a look at doc. Where computeCssClass is function of controller which takes sole argument and returns 'last' or null .
The ng-model binding will evaluate its expression on the current scope. As ng-repeat creates a child scope, this means that ng-model will look for a property named value on the child scope. In your example we'd expect it to look for the val property on the parent scope, which is aliased to t.
This is by design and can be circumvented in your case by referencing the parent scope t in the expression.
Working demo
Code (notice the binding on the input element has changed):
<section ng-repeat="t in test">
<div ng-repeat="(key,value) in t">
<div>{{key}}</div>
<input type="text" ng-model="t[key]"/>
</div>
</section>
As you're using a beta version of Angular 1.3, this may be a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With