Yep, that's the right way. I actually have a service called 'api' that defines all my $resource objects and then returns an object that references what I need the way I need it. For example:
service('api', ['$http','$resource','$q',
function($http, $resource, $q){
var Account = $resource('/api/account',{},{ get: { method: 'get' } })
var Settings = $resource('/api/settings',{},{ read: { method: 'get' }, save: { method: 'put'} })
var Reports = $resource('/api/reports/:reportName',{ reportName: '@ reportName' },{ loadReport: { method: 'get' }, update: { method: 'put'} })
return {
account: new Account(),
settings: new Settings(),
singleReport: function(){
return new Reports(); //case where I need an api resource for managing a report that doesn't save state across controllers it's injected into
}
}
}
])
//sample controller
function someController($scope, api){
$scope.settings = api.settings;
$scope.settings.$read( function success(dataReturned) {
console.log( 'is dataReturned really the same things as $scope.settings? ', dataReturned == $scope.settings); //true
});
$scope.myReport = api.singleReport();
$scope.myReport.$loadReport({{ reportName: 'gross-sales' }) //will call /api/reports/gross-sales and bind result to scope
}
Now my settings template in html will interpolate as soon as the api returns the result and the same settings will be anywhere I inject the service without needing to call $read again. There's even more magic you can do, but this is a good start for now... good job getting this far and questioning yourself, you are on the right path.