I have complex JSON output.
{"pages":[{"Page":{"id":"1","title":"My title"}}]}
How can I use it in view with angularjs foreach cycle?
Thank You.
Edit: Somebody had written a tip, but deleted it:) thank you.
I solved it this way
<ul>
<li ng-repeat="page in pages.pages"><a href="p/{{page.Page.id}}-{{page.Page.title}}">{{page.Page.title}}</a></li>
</ul>
I mean you almost have it right (?)
On the client:
function PagesController($scope, $http) {
$http.get('pages/index.json').success(function(data) {
$scope.pages = data.pages;
});
}
Within the view file:
<ul ng-controller="PagesController">
<li ng-repeat="obj in pages"><a>{{obj.Page.title}}</a></li>
</ul>
If you don't support the .json extension then just get it where ever you have it.
You can take look at this Format Associative JSON to Work With Knockout.js
Hope it helps