Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b950c75

Browse files
author
Michael Salmon
committed
docs(guide/Directives):
Updates high level overview for directive link function based on PR comments
1 parent 33d8a27 commit b950c75

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/content/guide/directive.ngdoc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,24 @@ want to reuse throughout your app.
587587
In this example we will build a directive that displays the current time.
588588
Once a second, it updates the DOM to reflect the current time.
589589

590-
Directives that want to modify the DOM typically use the `link` option, which is documented on the {@link ng.$compile `$compile` API} page.
591-
`link` takes a function with the following signature, `function link(scope, element, attrs, controller, transcludeFn) { ... }`, where:
590+
Directives that want to modify the DOM typically use the `link` option to register DOM listeners
591+
as well as update the DOM. It is executed after the template has been cloned and is where
592+
directive logic will be put.
593+
594+
`link` takes a function with the following signature,
595+
`function link(scope, element, attrs, controller, transcludeFn) { ... }`, where:
592596

593597
* `scope` is an Angular scope object.
594598
* `element` is the jqLite-wrapped element that this directive matches.
595599
* `attrs` is a hash object with key-value pairs of normalized attribute names and their
596600
corresponding attribute values.
597-
* `controller` is the controller for the directive, if defined.
598-
* `transcludeFn` is a transclude linking function pre-bound to the correct translusion scope.
601+
* `controller` is the directive's required controller instance(s) or it's own controller (if any).
602+
The exact value depends on the directive's require property.
603+
* `transcludeFn` is a transclude linking function pre-bound to the correct transclusion scope.
604+
605+
<div class="alert alert-info">
606+
For full detail on the `link` method refer to the {@link ng.$compile `$compile` API} page.
607+
</div>
599608

600609
In our `link` function, we want to update the displayed time once a second, or whenever a user
601610
changes the time formatting string that our directive binds to. We will use the `$interval` service

0 commit comments

Comments
 (0)