angularjs - ng repeat not updating -
hi newbie angular js , hoping can me out following problem.
i have numeric field called numadults , need show set of field (such name, address, telephone etc ) numadult times information each of person.
here jsfiddle problem jsfiddle link
here overview of code of controller
function bookingcontroller($scope){ $scope.numadults = 1; $scope.personloop = function(){ console.log('personloop called') return new array($scope.numadults); //return new array(2); }
the html
<label for="book_num_adults">number of adults:</label> <input id="book_num_adults" type="text" ng-model="numadults"> <div class="row" ng-repeat="t in personloop()" style="border:2px solid red;margin-top:10px"> <h4>person {{$index+1}}</h4> <input placeholder="name"><br> <input placeholder="address"><br> <input placeholder="telephone"><br> </div>
can me how transform module ( not controller based )
thank in advance!
your fiddle riddled errors...
- under frameworks & extensions, need change 2nd dropdown "onload" 1 of "no wrap" options
- your
controller
definition mangled. it's supposed be:.controller('name', ['depname', function (depname) { })]);
-- had closing array misplaced. - you should use semi-colons.
- you don't create array of 5 items in javascript this:
var = new array(5)
, creates array contains 5. instead, shouldvar = []; a.length = 5;
Comments
Post a Comment