Javascript 如何在angularjs中创建模块

Javascript 如何在angularjs中创建模块,javascript,angularjs,ngroute,angularjs-ng-route,Javascript,Angularjs,Ngroute,Angularjs Ng Route,在所有的angularjs教程中,我都经历过。模块创建如下 var newApp = angular.module('articles', []); angular.module('articles').controller('ArticlesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Articles', function($scope, $stateParams, $location,

在所有的angularjs教程中,我都经历过。模块创建如下

var newApp = angular.module('articles', []); 
angular.module('articles').controller('ArticlesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Articles',
  function($scope, $stateParams, $location, Authentication, Articles) {
    $scope.authentication = Authentication;
    .....
    .....

]);
或 var routerApp=angular.module('routerApp',['ui.router'])

我用meanjs锅炉板代码开始我的项目,控制器开始如下

var newApp = angular.module('articles', []); 
angular.module('articles').controller('ArticlesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Articles',
  function($scope, $stateParams, $location, Authentication, Articles) {
    $scope.authentication = Authentication;
    .....
    .....

]);
当我把它改成

var newApp = angular.module('articles',[]);
newApp.controller('ArticlesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Articles',
  function($scope, $stateParams, $location, Authentication, Articles) {
    $scope.authentication = Authentication;
    .....
    .....

]);
所有的物品路线都停止工作。如果我想在模块中包含一个新组件,我该怎么做。我想将angularFileUpload添加到我的模块中

angularfileupload中的示例代码为

angular
    .module('app', ['angularFileUpload'])
    .controller('AppController', function($scope, FileUploader) {
        $scope.uploader = new FileUploader();
    });
如果模块已注册,如何添加['angularFileUpload']? 编辑:

articles.client.modules.js

'use strict';

// Use Applicaion configuration module to register a new module
ApplicationConfiguration.registerModule('articles');
angular.module(“MyModule”,[])
(带
[]
)是一个setter函数,也就是说,它注册一个模块

angular.module(“MyModule”)
不带
[]
是一个getter函数,它检索以前注册的模块

两次调用setter将重新定义模块

我不熟悉meanjs样板文件,但很可能当您使用setter时,您已经重新定义了模块以及任何控制器、服务、配置等。。。以前注册的已被覆盖

您只需更改添加到的内容:

var newApp = angular.module("articles");
例如:

angular.module("M", []).controller("A", function(){}); // module M has controller A

angular.module("M").controller("B", function(){}); // module M has controllers A, B

var app = angular.module("M", []); // module M re-registered
app.controller("C", function(){}); // module M has controller C only
用法


是的,该模块在另一个文件中注册为ApplicationConfiguration.registerModule('articles');。如何在不重新定义模块的情况下将新组件添加到此模块中?使用getter:
angular.module(“articles”)
MEAN不使用变量声明新模块,始终对所有组件使用
angular.module
。在上述情况下,我是否添加angularFileUpload?我不理解您的评论。将angularFileUpload添加到什么?