Struggling to implement the angular-js $resource function in an app built with the ionic framework. Having trouble getting it to work. Relevant code:
Service.js
.factory('Pages', function($resource) {
var source = $resource("http://localhost:5432/api/pages",{},
{query: { method: "GET", isArray: false }});
return source;
})
controllers.js
.controller('PagesCtrl', function($scope, Pages) {
$scope.pages = Pages.query();
$scope.results = $scope.pages.results;
console.log($scope.results);
})
browse.html
<ion-view view-title="Browse">
<ion-content>
<h1>Browser</h1>
<ion-list>
<ion-item ng-repeat="page in results">
<h2>{{page.title}}</h2>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
and the data
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"parent": null,
"title": "Blog",
"content": "<p>Blog</p>",
"content_model": "richtextpage",
"slug": "blog",
"publish_date": null,
"login_required": false,
"meta_description": "Blog",
"tags": ""
},
{
"id": 2,
"parent": null,
"title": "Lorem Ipsum",
"content": "Lorem ipsum ....",
"tags": ""
}
]
}
Despite efforts, the console log (in controllers.js) consistently shows 'undefined'. Been troubleshooting for hours without success.