angular.module('newProjectApp') .controller('MainCtrl', function ($scope, Device) { Device.all() .success(function(data) { $scope.devices = data }) .error(function(data) { $scope.error = 'Unauthorized. Login first.' }) });