0

I have angular app as below:

var myapp= angular.module('myapp',
['ngAnimate','ngDialog','angularUtils.directives.dirPagination','yaru22.angular-timeago','ui.date','textAngular'])

Now I want to add 'textAngular' dependencies separately so that I don't have to add all the related files in my layout/header file.

I have different controller files for every controller so I am trying something like below in my controller file which is separate from file where I have defined my app:

myapp.config(function(textAngular) {

   $provide.decorator('taOptions', ['$delegate', function(taOptions){

       taOptions.toolbar = [

           //['h2', 'h3', 'h4'],

           ['p'],

           ['bold', 'italics'],

           ['redo', 'undo', 'clear'],

           ['insertLink'],

           ['wordcount', 'charcount']

       ];

       return taOptions;

   }]);

}).

run(function(textAngular) { // instance-injector

   // This is an example of a run block.

   // You can have as many of these as you want.

   // You can only inject instances (not Providers)

   // into run blocks

});

But This method is not working. As mentioned in SO question config can only be used to add providers and textAngular is I think module.

Community
  • 1
  • 1
Always_a_learner
  • 4,585
  • 13
  • 63
  • 112
  • 1
    To use other modules inside your module there is no way of getting around a list of dependencies. A good solution for a big project would be to split the project into different modules, which semselves might depend on only a few other modules. Your main module would then just depend on your own submodules. This will alsow make it easier to reuse some of the code you did, because you would not need to depend on the complete application, but only one of the modules. – Tobi Nov 02 '16 at 08:59
  • @Tobi So for every diiferent section of project I should define a different module i.e ng-app? I don't want have separate ng-app for different parts of my project. – Always_a_learner Nov 02 '16 at 09:01
  • You won't need to bootstrap all these submodules to the DOM. You will have one ng-app directive containing your "myapp". Your "myapp" module would then depend for example on a "myapp.components" module, which will only depend on stuff, the controllers and components in this module require. – Tobi Nov 02 '16 at 09:50

0 Answers0