ianaz ianaz - 5 months ago 32
AngularJS Question

AngularJS Two directives with the same module name

Is it possible to create two directives with the same module name?
Having this two files

angular.module('fabTemplate', [])
.directive('fabGallery', [function () {


angular.module('fabTemplate', [])
.directive('fabVideo', [function () {

The second directive will not be recognised.

<fab-video />

does not render anything. By changing the module name works though.

AngularJS's documentation says that the parameter name (first param of module "method")

The name of the module to create or retrieve.

I suppose that should work then... :S
Angular doesn't print anything into the console


If you want to retrieve a module, then you must use only the first param of angular.module().

From the docs:

requires (optional) [Array.] : If specified then new module is being created. If unspecified then the the module is being retrieved for further configuration.

Your code should be something like:

//Module definition:
angular.module('fabTemplate', []);

//Get the module and add the first directive:
angular.module('fabTemplate').directive('fabGallery', function () {});

//Get the module and add the second directive:
angular.module('fabTemplate').directive('fabVideo', function () {});