I am new to AngularJS, and I have a problem with ng-model.
Here's my code:
<section class="field row" ng-repeat="field in fields">
<input class="value" ng-show="editMode" placeholder="{{field.name}}" ng-model="field.value" type="url" />
</section>
As you can see, I'm looping through $scope.fields
which I got from the server and is an array of about 40 objects that have keys like name
and value
.
Inside the section I have an input, which has the ng-model
property set to field.value
. When the server gives a value to the field, it is shown inside the input.
At some point I want to update the user's changes, by sending $scope.fields back to the server.
However, when the user changes something in the inputs, the value
for the changes fields becomes undefined
.
I hope this describes my problem well enough.
Thanks!