The example code you've provided doesn't really make a lot of sense. Firstly the data wont be available on your page because you haven't added it to the scope. demo.data
should look similar to $scope.data
ng-repeat is added to an element of your html. You can also add some 'keywords' such as orderBy and 'unique' to manipulate how the output is handled by angular.
Every element nested inside our repeating <li>
will be repeated for each json object in data
. This data will have it's year, month and item value written to the page where the {{}}
enclosed values are. For instance {{date.year}}
will display the date's year.
The orderBy: 'year'
will arrange the dates by the year, and the unique: 'item'
will ensure only one object with the item value is provided.
<ul>
<li ng-repeat="date in data | unique:'item' | orderBy: 'year'">
<span>{{date.year}}</span>
<ul>
<li>
<span>{{date.month}}</span>
<ul>
<li>
<span>{{date.item}}</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
You need to do a little more research before asking a question. You've essentially just asked somebody to write you code for you. Even if you were to copy what I, or anyone else, gave you I don't think you yet have the understanding of angular to actually implement it. Please spend some more time learning angular and you'll find it's actually quite easy!
Here are some resources regarding ng-repeat to check out;
https://docs.angularjs.org/api/ng/directive/ngRepeat
https://www.w3schools.com/angular/ng_ng-repeat.asp
EDIT: You plunker example is very different from the kind of result I thought you were after.