别样的角度指令模式 [英] Different kind of Angular Directives patterns

查看:115
本文介绍了别样的角度指令模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

angular.directive('ppd:reset', function(e1,e2) {
    return function(linkElement) {      
        linkElement.wrap()....
        });
    };
});

angular.directive('ppd:reset', [function() {
        return function(scope, elm, attrs) {   } 

}]);

什么是这两个指令模式之间的区别?

What is the difference between these two directives pattern ?

推荐答案

如果你用括号来声明你的工厂,你可以与缩小你的code时避免出现问题:

If you declare your factories with the bracket notation, you can avoid problems when minifying your code:

angular.directive('ppd:reset', ["$compile", function(compile) {
    return function(scope, elm, attrs) {   } 

}]);

喷油器看你的函数的参数名称,才能知道注射什么。如果一个微小的过程重命名这些,喷油器不知道该怎么办了。微小当然不会碰字符串值,这就是为什么数组符号正常工作。

The injector looks at your function parameter names in order to know what to inject. If a minification process renames those, The injector doesn't know what to do anymore. Minification will of course not touch string values which is why the array notation works fine.

这篇关于别样的角度指令模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆