Hello, I'm a beginner in Angular and I'm finding it very nice, my problem is this:
I have a ng-repeat that works fine when I get the data source of a javascript variable like this:
var alertsq = [
{
"alert":"mediun",
"nt":"28",
"nu":"28",
"no":"34",
"dtini":"2012/Jul/23",
"no":"3",
"dtoc":"23/7/2012",
"dtuo":"25/7/2012",
"id":"227529436529033216",
"msg":"Uh oh, this could be bad. Check the door lock vendor before you book you next hotel room: http://t.co/n56emZf2"
},
{
"alert":"mediun",
"nt":"28",
"nu":"28",
"no":"34",
"dtini":"2012/Jul/23",
"no":"3",
"dtoc":"23/7/2012",
"dtuo":"25/7/2012",
"id":"227529436529033216",
"msg":"Uh oh, this could be bad. Check the door lock vendor before you book you next hotel room: http://t.co/n56emZf2"
}];
My controller that takes the variable alertsq and arrow in scope is like this:
app.controller("alertsController", function(){
console.log(alertsq);
this.alerts = alertsq;
});
The cool thing is that this works and my list in *ng-repeat*
is filled beautifully, but when I use $ http to load a JSON content from a file it does not populate the list: of the controller looks like this:
app.controller("alertsController", function($http,$scope){
$http({
url: "data/alerts.json",
dataType: "json",
method: "GET",
headers: {
"Content-Type": "application/json"
}
}).success(function(data){
$scope.alerts = data;
console.log($scope.alerts);
}).error(function(error){
console.log(data);
console.log(error);
});
});
The cool thing is that JSON is coming right out of the browser in the first case in that the list is filled is like this:
mainController controller.js:7
[Object, Object, Object, Object, Object, Object, Object]
0: Object
$$hashKey:"object:4"
alert: "mediun"
dtini: "2012/Jul/23"
dtoc: "23/7/2012"
dtuo: "25/7/2012"
id: "227529436529033216"
msg: "Uh oh, this could be bad. Check the
door lock vendor before you book you next hotel room:
http://t.co/n56emZf2"
no:"3"
nt: "28"
nu: "28"__proto__:
Object1:
Object2:
And this is the output of the console when I search for $ http the JSON:
[Object, Object, Object, Object, Object, Object, Object]
0: Object
alert: "mediun"
dtini: "2012/Jul/23"
dtoc: "23/7/2012"
dtuo: "25/7/2012"
id: "227529436529033216"
msg: "Uh oh, this could be bad. Check the
door lock vendor before you book you next hotel room:
http://t.co/n56emZf2"
no:"3"
nt: "28"
nu: "28"__proto__:
Object1:
Object2:
The detail is that in the output obtained by JSON through $ http there is no $$ hashKey attribute, and so the list in ng-repeat is not filled :(, can anyone help me to solve this?
Thank you for your attention!