Build a Debug Directive

Share this video with your friends

Send Tweet

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

Marty
Marty
~ 10 years ago

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?

John Lindquist
John Lindquist(instructor)
~ 10 years ago

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.

Marty
Marty
~ 10 years ago

Thanks John.