My REST server is returning the following from /blog
:
["hello","yo"]
This is my entire angularjs app:
var myapp = new angular.module("myapp", ["ngResource"]);
myapp.controller("MainCtl", ["$scope", "$resource", function($scope, $resource){
var Blog = $resource("/blog/:entry", {entry: '@entry'});
$scope.entries = Blog.query();
}]);
When I put {{entries}}
somewhere in the html, I see this: [{"0":"h","1":"e","2":"l","3":"l","4":"o"},{"0":"y","1":"o"}]
Somehow angular is misinterpreting this array of values. I also tried this with exactly the same results:
myapp.controller("MainCtl", ["$scope", "$resource", function($scope, $resource){
var Blog = $resource("/blog/:entry", {entry: '@entry'}, {
list: {
url: "/blog",
method: "GET",
isArray: true,
transformResponse: function(data, headers) {
var h = ["hello","yo"];
console.log(h);
return h;
}
}
});
$scope.entries = Blog.list();
}]);
Interestingly, that console.log
call prints the correct value.