It must be the scorching temperature...
Having a json object that I'm eager to loop through using ng-repeat, it should be straightforward, but alas! it's just not cooperating.
Here's the HTML snippet:
<a data-ng-repeat="x in template.menuObj" href="{{ x.link }}">{{ x.name }}</a>
JSON Data:
[
{
"ACL":{
"*":{
"read":true
}
},
"link":"home",
"menu":"main",
"name":"Home",
"order":1,
"objectId":"aDcb0HUXwB",
"createdAt":"2015-08-05T15:29:05.948Z",
"updatedAt":"2015-08-05T15:29:11.915Z"
},
{
"ACL":{
"*":{
"read":true
}
},
"link":"category/the-interesting-stuff",
"menu":"main",
"name":"The Interesting Stuff",
"order":2,
"objectId":"znXfUF0kdJ",
"createdAt":"2015-08-05T15:33:11.332Z",
"updatedAt":"2015-08-05T15:33:39.738Z"
},
{
...
]
Running this results in 5 empty <a>
elements like this:
<a data-ng-repeat="x in template.menuObj" href="" class="ng-binding ng-scope"></a>
Seems like Angular recognizes the 5 arrays, but for some reason, the keys aren't being captured?
EDIT: The creation of the JSON object looks something like this (using parse.com):
var Menu = Parse.Object.extend('Menu');
var query = new Parse.Query(Menu);
query.ascending('order');
query.equalTo('menu', 'main');
query.find().then(function(results){
console.log(JSON.stringify(results));
$scope.template.menuObj = results;
}, function(error){
// error-handling
console.log("Error: " + error.code + " " + error.message);
});
EDIT EDIT: Controller details:
blogApp.controller('templateCtrl', function($scope, templateService) {
$scope.template = templateService;
var Menu = Parse.Object.extend('Menu');
var query = new Parse.Query(Menu);
query.ascending('order');
query.equalTo('menu', 'main');
query.find().then(function(results){
console.log(JSON.stringify(results));
$scope.template.menuObj = results;
}, function(error){
// error-handling
console.log("Error: " + error.code + " " + error.message);
});
});
templateService is a factory that connects to a parent controller. It's worth noting that prior to incorporating parse.com into this project, the ng-repeat functioned perfectly when fetching a json object via PHP/MySQL using $http.
EDIT EDIT EDIT: Check out the screen capture of console.log(results);
https://i.sstatic.net/DIgqu.png