Do the parameters of a directive's link function rely on DI?

ejoubaud picture ejoubaud · Apr 8, 2013 · Viewed 14.1k times · Source

In:

module.directive 'name', ->
  (scope, element, attr) ->
    # Whatever implemenation

Do the scope, element and attrs parameters of the link function rely on name-inferred Dependency-Injection? If yes, how can I make them minification proof ?

Or do they rely on good old arguments order for what's passed into them ?

Answer

Arun P Johny picture Arun P Johny · Apr 8, 2013

No, the link function has a predefined set of parameters.

function link($scope, $element, attrs, ctrl) {
    //Your method
}

They are

  1. Scope of the element
  2. The element itself (jquery/mini jquery wrapped)
  3. Attribute set of the element
  4. Any controllers used in required