Angularjs 指令模版

查看更多文章: https://alili.tech
myModule.directive('namespaceDirectiveName', function factory(injectables) {

    var directiveDefinitionObject = {
        restrict: string,//指令的使用方式,包括标签,属性,类,注释
        priority: number,//指令执行的优先级
        template: string,//指令使用的模板,用HTML字符串的形式表示
        templateUrl: string,//从指定的url地址加载模板
        replace: bool,//是否用模板替换当前元素,若为false,则append在当前元素上
        transclude: bool,//是否将当前元素的内容转移到模板中
        scope: bool or object,//指定指令的作用域
        controller: function controllerConstructor($scope, $element, $attrs, $transclude){...},//定义与其他指令进行交互的接口函数
        require: string,//指定需要依赖的其他指令
        link: function postLink(scope, iElement, iAttrs) {...},//以编程的方式操作DOM,包括添加监听器等
        compile: function compile(tElement, tAttrs, transclude){
            return: {

                pre: function preLink(scope, iElement, iAttrs, controller){...},
                post: function postLink(scope, iElement, iAttrs, controller){...}
            }

        }//编程的方式修改DOM模板的副本,可以返回链接函数
    };

    return directiveDefinitionObject;

});


公众号“ Alili丶前端大爆炸”,关注后提供海量学习资料

图 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值