Vijey Vijey - 5 months ago 44
AngularJS Question

Angularjs: $scope vs scope

In Angularjs, is there a specific reason to use

in controllers and
) in directives link function? Is it just a convention or anything else?


The case when you do $scope in controller the Dependency Injection injects scope based on matching the variable name $scope, in this case using scope as name would not work.

For case of directive the injection is position based so you can name your variable a or b or any thing. The directive order for link function is

(scope, iElement, iAttrs, controller)

so first element is always scope object.