Just supply a service or factory.
angular.module("myApp", []). factory("CompanyResource", function ($resource) { return $resource("/company/:_id", {_id: "@_id"}); });
and then you can use it in the controller with
function MapCtrl($scope, $resource, $location, CompanyResource) { ... CompanyResource.query(); ... }
Note that you do not need the $ sign in front of the factory name.
source share