加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 09:15:27 所属栏目:安全 来源:网络整理
导读:是否可以创建具有相同模块名称的两个指令? 拥有这两个文件 angular.module('fabTemplate',[]) .directive('fabGallery',[function () {.... 和 angular.module('fabTemplate',[]) .directive('fabVideo',[function () {... 第二个指令将不被承认. fab-video
是否可以创建具有相同模块名称的两个指令?
拥有这两个文件
angular.module('fabTemplate',[])
    .directive('fabGallery',[function () {
....

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

第二个指令将不被承认.

<fab-video />

不渲染任何东西.通过更改模块名称.

AngularJS的documentation says的参数名称(模块“method”的第一个参数)

The name of the module to create or retrieve.

我想这应该工作,然后…:S
角度不会在控制台中打印任何东西

如果要检索模块,则必须仅使用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.

你的代码应该是这样的:

//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 () {});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读