The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Build a Debug Directive

Build a Debug Directive

4:00
Explore some interesting techniques with AngularJS directives to create a debug directive using termination, priority, and the $compile service.
Watch this lesson now
Avatar
egghead.io

Explore some interesting techniques with AngularJS directives to create a debug directive using termination, priority, and the $compile service.

Avatar
Marty

This is a question that I derived from the video but it is off topic.

In the video scope and element had to be passed (injected) into the linking function so they could used. Then the $compile had to be passed (injected) into the directive so it could be used.

Sometimes functionality is injected directly into the link function and sometimes it's injected into the directive.

What is the difference between functionality passed into the linking function and functionality passed into the directive?

Avatar
John

The directive uses angular's injection (you can inject services, etc).

The link function only takes arguments (scope, element, attrs, ctrl, transclude) which can't be changed. You can't inject services, etc into the link function since angular always calls it with those arguments.

In reply to Marty
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?