1

我正在尝试将 angular-gantt 插件添加到我的应用程序中。首先;

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

然后,当我的应用程序需要 angular-gantt 时,我想向“myApp”添加一些额外的模块,例如;

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

但是当我这样做时,页面消失了,没有任何效果。我怎么解决这个问题。

4

1 回答 1

1

添加到现有模块时需要使用不同的语法,否则模块会被重新创建/覆盖。从https://docs.angularjs.org/guide/module

请注意,使用 angular.module('myModule', []) 将创建模块 myModule 并覆盖任何名为 myModule 的现有模块。使用 angular.module('myModule') 检索现有模块。

以及以下示例:

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');

编辑:还请在此处查看更详细的讨论: 重新打开并将依赖项添加到已引导的应用程序

于 2015-04-20T15:53:55.333 回答