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 existing one. From all the documentation and examples I've seen, this parameter is always passed an empty array when used. My question is, is requires
meant to be used for anything else besides telling Angular to create a new module instead of getting an existing one? What would happen if I instead passed it a non-empty array? Are those values used for any other purpose? Links with solutions are much appreciated. Thanks.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With