角连接功能:$范围VS范围 [英] Angular Link Function: $Scope vs Scope
问题描述
在角指示我的教程已经看到无论是
In angular directives I've seen in tutorials either
link: function($scope,$element,attrs)
或
link: function(scope,element,attrs)
现在我知道,$的角是指一个服务,这是否持有吗?究竟什么是$范围和范围之间的区别?同去的元素VS $元素
Now I know that the '$' means a service in angular , does this hold here ? What exactly is the difference between $scope and scope ? Same goes to element vs $element
推荐答案
在您的具体的例子,它并不重要的参数在你的链接功能命名。当角处理指令,它就会范围,要素和ATTRS(即使配置了控制器实例)传递给您的链接功能。
In your specific example, it does not matter what the parameters are named in your link function. When Angular processes the directive, it will pass the scope, element and attrs (and even a controller instance if configured) to your link function.
您可以做到这一点(不推荐):
You could do this (not recommended):
link: function (s, e, a)
和它会正常工作。
$是角使用的preFIX。这是一个惯例,有助于避免命名冲突。
$ is the prefix used by Angular. It is a convention and helps avoid naming collisions.
这篇关于角连接功能:$范围VS范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!