1

I am trying to add angular-gantt plugins to my application. Firstly;

angular.module('myApp',['directives', 'services', 'controllers', ... and some more]

Then when I need angular-gantt on my application I want to add some extra modules to 'myApp' like;

angular.module('myApp',['gantt','gantt-sortable','gantt-movable',.. and some more]

But when I do that pages disapper and nothing works. How can I solve this problem.

4
  • Check the console for errors. Do you include your library files in your HTML page ? Commented Apr 20, 2015 at 14:41
  • Show us the console log and the code itself Commented Apr 20, 2015 at 14:44
  • Are both those 2 lines running in your code? Or just the one? Commented Apr 20, 2015 at 15:52
  • The project is too big to share. When I try to add new modules, existing modules are lost. This is the problem. I want to add new modules to 'myApp' without losting existing ones. Commented Apr 21, 2015 at 6:33

1 Answer 1

1

You need to use different syntax when adding to existing module, otherwise the module gets recreated/overwritten. From https://docs.angularjs.org/guide/module:

Beware that using angular.module('myModule', []) will create the module myModule and overwrite any existing module named myModule. Use angular.module('myModule') to retrieve an existing module.

and the example that follows:

var myModule = angular.module('myModule', []);

// add some directives and services
myModule.service('myService', ...);
myModule.directive('myDirective', ...);

// overwrites both myService and myDirective by creating a new module
var myModule = angular.module('myModule', []);

// throws an error because myOtherModule has yet to be defined
var myModule = angular.module('myOtherModule');

Edit: please also look here for much more detailed discussion: re-open and add dependencies to an already bootstrapped application

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.