Good day! There is an array of approximately this content, obtained from the backend

[ { 'first': 1 }, { 'second': 2, { 'third': 3 } ] 

I bring it not the page

 <div ng-repeat="d in ctrl.data"> <div ng-repeat="(key, value) in d"> {{key}} <input ng-model="value"/> </div> </div> <button ng-click="ctrl.updateData()">zhmyak</button> 

I get the output in the form of text - input with value. Next I want to fix the value in the input and send back to the backend

The controller looks like this:

 function myController(apiResource) { var vm = this; vm.data = []; vm.updateData = updateData; getData(); function getData() { return apiResource.stats.get().$promise.then( function (data) { vm.data = data['stats'] } ) } function updateData() { return apiResource.stats.put( {stats: vm.data} ) } } 

When correcting the value in the input and trying to send it back, the original values ​​(not corrected) are sent. How to force to send updated data?

    1 answer 1

    Each ng-repeat element has its own scop, so you can't just bind to the field. It should be ensured that the first step is to read the subfield:

     <input ng-model="d[key]" />