I found lots of posts on this issue and tried to implement some of the solutions proposed here:
But it still does not work and I am wondering if using firebase could be an issue. I have created a service linking to my Firebase datasource:
servicesModule.factory("postsDB", function($resource){
return $resource("https://<datasource>.firebaseio.com/Posts/:id", {
id: "@id"
},
{
update: {
method: "PUT",
isArray : true
}
});
});
Then my controller:
controllersModule.controller('BlogCtrl', ["$scope", "postsDB", function($scope, postsDB) {
postsDB.query(function(posts){
$scope.myPosts = posts;
})
}]);
The ng-repeat result:
<div class="col s12 m6" id="postItems" ng-repeat="post in myPosts">
<h3>{{post.Title}}</h3>
{{post.Body}}
{{post.Author}}
</div>
I really do not understand what:
Error: $resource:badcfg Response does not match configured parameter
means (as usual with angular errors) except that it is obviously expecting an array and I though that the whole point of using postsDB.query
was to do just that. I have added isArray: true above but it has no effect whatsoever. Why aren't my posts being loaded if the resource exists as a JSON posts array?