xxlali
xxlali

Reputation: 1036

Add Angular Module

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.

Upvotes: 1

Views: 1196

Answers (1)

wmz
wmz

Reputation: 3685

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

Upvotes: 1

Related Questions