angular.module('app') .controller('PkGuidController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', function($scope, $state, $mdDialog, pkGuidBusiness) { $scope.selected = []; $scope.query = { order: 'someText', limit: 5, page: 1 }; $scope.pkGuids = null; $scope.pkGuidsError = null; $scope.getPkGuids = function() { $scope.pkGuidsError = null; var orderBy = $scope.query.order; if (orderBy[0] == '-') { orderBy = orderBy.substr(1) + ":DESC"; } else { orderBy = orderBy + ":ASC"; } $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.page - 1, $scope.query.limit).then(function(data) { $scope.pkGuids = data; $scope.pkGuidsError = null; }, function(error) { $scope.pkGuids = null; $scope.pkGuidsError = error; }); }; $scope.getPkGuids(); // pkGuidBusiness.getSingleById('42').then(function(data) // { // console.log(data); // }, function(error) // { // console.error(error); // }); }]);