0

AngularJs source:

<html ng-app>
  <body ng-controller="Controller">
    <div ng-init="numbers=[11,22,33]">
       <div ng-repeat="n in numbers">
         <input type="text" ng-model="n"/> [{{n}}]
       </div>
    </div>
    <script>
        function Controller($scope) {}
    </script>
  </body>
</html>

When I change the value of the inputs, the text on the right won't be updated. Where is wrong?

The live demo is here: http://jsfiddle.net/Freewind/TZwxy/

You can change the value in the inputs and see.

Zaphod
  • 6,758
  • 3
  • 40
  • 60
Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

1

Try with an array of objects instead:

function Controller($scope) {
  $scope.numbers = [{value: 11 }, {value: 22 }, {value: 33 }];
}

<html ng-app>
  <body ng-controller="Controller">
    <div>
       <div ng-repeat="n in numbers">
         <input type="text" ng-model="n.value"/> [{{n.value}}]
       </div>
    </div>
  </body>

</html>

See jsFiddle.

asgoth
  • 35,552
  • 12
  • 89
  • 98