I\'m making a document editor. Documents can be Type A or Type B. They are accessed by url by document id, but the id does not make it clear if the document is of type A or
You could have a Documents service which owns and provides an API to all the document data. The controllers then inject the Documents service, and reference the document they're interested in on their scope.
Something like:
app.service('Documents', function(){
Documents = {};
return {
open: function(doc_id) { ... } // loads and caches doc (if not already cached) and returns a promise with a reference to Documents[doc_id]
sync: function(doc_id) { ... } // sync doc with server
close: function(doc_id) { ... } // remove doc_id from Documents
};
});
app.controller('editX', function($scope, $stateParams, Documents){
Documents.open($stateParams.documentId).then(function(ref){
$scope.document = ref;
});
...
})