Dawson Dawson - 5 months ago 15
AngularJS Question

Populate <dl> list from array

I am using angularJS and have a javascript array of objects, each object has

Count
ID
Subject


I would like to use this array to populate a with these values:

<dl>
<dt>Count</dt>
<dd>Subject</dd>
<!--all objects should appear as above-->
</dl>


Is there a way to do this?

Answer
$scope.yourArray = [
    {"Count": "something1", "ID":  "something2", "Subject":  "something3"},
    {"Count": "something1", "ID":  "something2", "Subject":  "something3"},
    {"Count": "something1", "ID":  "something2", "Subject":  "something3"},
    {"Count": "something1", "ID":  "something2", "Subject":  "something3"}
]; // On the controller

<dl ng-repeat="item in yourArray">
    <dt>{{item.Count}}</dt>
    <dd>{{item.Subject}}</dd>
</dl>
Comments