I'm trying to print an array using a loop in Javascript in Angular JS -
i'm trying print out each array item property in object:
{ position:"finance office assistant", employer:"washtenaw county finance department", location:"ann arbor, mi", start_date:"2012", current: false, end_date:"2012", duties: [ "item 1", "item 2", "item 3" ] },
this object in array, several other objects. i'm trying create function loops through of objects , prints out duties array items in unordered list exact number of list items , array items.
here function i'm trying write task
$scope.dutylist = function() { var arraylength = $scope.duties.length; while (arraylength > 0) { console.log("dutylist run") document.write("<li> {{ dutylist }} </li>"); --arraylength; } }
you don't need function handle displaying data this. angular's ngrepeat this. access second level of of data set can nest 2 repeats in unordered list. first 1 (in div) repeats first layer of data, , exposes second layer, repeat in <li>
tag:
<ul> <div ng-repeat="d in data"> <li ng-repeat="duty in d.duties">{{duty}}</li> </div> </ul>
Comments
Post a Comment