I'm pretty new to Angular and am looking for some help with basic concepts. At the moment I have one module that has functions and attributes that I would like to access in a separate module.
Here's the code I would like to access:
(function() {
'use strict';
var recentItemRepoDep = [
'repository',
recentItemRepository
];
var repoName = 'spRecentItemRepository';
angular
.module('repository')
.run(repoSelfRegister(repoName))
.factory(repoName, recentItemRepoDep);
function recentItemRepository(repository) {
var repo = repository('APIRecentItem', {
primaryKeys: [/*'UserName',*/ 'ItemID']
});
return repo;
}
})();
And here's the beginning of the code I'm trying to implement the previous code in:
(function() {
'use strict';
var salesDocumentMenuCtrlDep = [
'$scope',
'$state',
'$stateParams',
'repos',
'spTabBarViewModel',
'spLoader',
'spCurrentUser',
'salesDocsVal',
salesDocumentMenuCtrl
];
angular
.module('salesDocumentModule')
.controller('salesDocumentMenuCtrl', salesDocumentMenuCtrlDep);
I'm wondering if there's a way to inject one module into another one but nothing I've tried has worked so far.
You can inject other modules in one main module like this:
angular
.module('mainModule', ['other', 'modules', 'goes', 'here']);
And this injected modules can have other injected sub modules, and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With