Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include Angular modules in separate Module

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.

like image 260
essenbsa Avatar asked May 29 '26 01:05

essenbsa


1 Answers

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.

like image 57
Commercial Suicide Avatar answered May 31 '26 15:05

Commercial Suicide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!