Running my factory:
serviceCall:
'use strict';
app.factory('serviceCall', ['$resource', 'ngAuthSettings', function ($resource, ngAuthSettings) {
var serviceBase = ngAuthSettings.apiServiceBaseUri;
return $resource(serviceBase + 'api/category/', {}, {
update: {
method: 'PUT'
},
getAllByCategory: {
url: serviceBase + 'api/category/GetAllByCategory',
method: 'GET', isArray: true
}
});
}]);
Now onto my controller:
displayController:
'use strict';
app.controller('displayController',
['ngAuthSettings', '$scope', 'serviceCall', '$routeParams', '$location',
function (ngAuthSettings, $scope, serviceCall, $routeParams, $location) {
function initialize() {
var searchQuery = $location.search();
var keywords = searchQuery.keywords;
var informationModel = serviceCall.getAllByCategory({ categoryId: 2, page: $routeParams.page });
$scope.categoryInformation = informationModel.ads;
$scope.totalItemCount = informationModel.totalCount;
$scope.pagingSize = ngAuthSettings.maxPagingSize;
}
initialize();
}]);
Curious as to why informationModel.ads
is consistently undefined. Is there a better approach to calling $resource
custom methods in controllers?