AngularJS 两个具有相同模块名称的指令

2024-03-06

是否可以创建两个具有相同模块名称的指令? 有了这两个文件

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

and

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

第二条指令将不被承认。

<fab-video />

不渲染任何东西。不过,通过更改模块名称就可以了。

AngularJS 的文件说 http://docs.angularjs.org/api/angular.module参数名称(模块“method”的第一个参数)

要创建的模块的名称或检索.

我想那应该可行......:S Angular 不会在控制台中打印任何内容


如果您想检索模块,则必须仅使用 angular.module() 的第一个参数。

来自文档 http://docs.angularjs.org/api/angular.module:

需要(可选)[Array.]:如果指定,则正在创建新模块。如果未指定,则将检索模块以进行进一步配置。

你的代码应该是这样的:

//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 () {});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AngularJS 两个具有相同模块名称的指令 的相关文章

随机推荐