angular.module meaning of the second parameter “requires”

前端 未结 2 639
离开以前
离开以前 2021-01-03 03:43

Recall the method signature for angular.module. If the second parameter, requires is provided, then we are creating a new module instead of retrieving an existi

2条回答
  •  隐瞒了意图╮
    2021-01-03 04:22

    requires meaning an array of modules which your module depends.

    example:

    moduleA.js

    var customModule = angular.module ('ModuleA');
    // controller, services, factories , etc codes here
    

    app.js (main app)

    var app = angular.module ("app", ["ModuleA"]);
    

    if I just use:

    angular.module ("app");
    

    It means that i'm just retrieving the module named "app". Which is useable when controllers or directives or factories is defined in a different JS files and you want to configure it to the module "app"

提交回复
热议问题