0

This one it might be an oldy but anyway I guess there are a lot of front-end developers with the wisdom.

I'm trying not to declare a plug-in into the main module of my application.

Let's say I have the following modularization:

SUB-COMPONENT MODULE

(function () {
'use strict';

         angular.module('app.modules.table.detail', []);

})();

COMPONENT MODULE

(function () {
'use strict';

         angular.module('app.modules.table', [
                  'app.modules.table.detail'
         ]);

})();

MAIN APP MODULE

(function() {
'use strict';

     angular.module('app.modules', 
        [ 'app.modules.table' <----// inside here is the table.detail 
         ,'app.modules.other.component'
        ]);


     angular.module('app', ['app.modules',

                             'smoothScroll']) 

So, with this structure, can I hide the smoothScroll third-party away from the app module array? I just want to declare app.modules and that's it for the app.

I tried to include it as a dependency in the component array, but no luck. I've been reading about and I guess it has to be on the app for the $injector to know his $provider.

Anyone have nailed this?

5
  • $injector is for services, not modules. Have you considered lazy-loading? ocLazyLoad might be an option Commented Oct 26, 2017 at 14:55
  • I will give it a look if avoids smoothScroll from showing. Commented Oct 26, 2017 at 15:09
  • I can see that ocLazyLoad would be another module on the app. I was wondering if it is possible to do it without any adds-on. I mentioned $injector before because maybe, maybe, I can declare the smoothScroll as a service and inject its $provider. Commented Oct 26, 2017 at 21:41
  • Then your question becomes quite philosophical. You can inject it differently, or you can hide it within nested modules Commented Oct 27, 2017 at 8:29
  • I guess yes, it is philosophical. And existencial, where does all begins and ends. Commented Oct 27, 2017 at 9:14

1 Answer 1

0

I will answer myself because it was easier than I thougt.

I was not declaring the third-party in the sub-component / component modules.

CHILD module component

(function () {
'use strict';
angular.module('app.modules.table.detail', ['smoothScroll']); <-- HERE!
})();

PARENT module component

(function () {
'use strict';

angular.module('app.modules.table', ['app.modules.table.detail', 'smoothScroll' <--- ALSO HERE
]);
})();

So now I can bootstrap the app with no need of declaring the third-party on the main module. Therefore it is hidden from the main app module file

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.