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

Commit 8a944b0

Browse files
hahlagkalpak
authored andcommitted
docs(guide/Directives): improve description of linking function
The `controller` and `transclude` parameters of the linking function were not mentioned in the description, but used in the examples. This commit improves the description and links to the `$compile` API docs for more details. Closes #13028
1 parent 786a1a4 commit 8a944b0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/content/guide/directive.ngdoc

+13-3
Original file line numberDiff line numberDiff line change
@@ -587,14 +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.
591-
`link` takes a function with the following signature, `function link(scope, element, attrs) { ... }`
592-
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:
593596

594597
* `scope` is an Angular scope object.
595598
* `element` is the jqLite-wrapped element that this directive matches.
596599
* `attrs` is a hash object with key-value pairs of normalized attribute names and their
597600
corresponding attribute values.
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 more details on the `link` option refer to the {@link ng.$compile#-link- `$compile` API} page.
607+
</div>
598608

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

0 commit comments

Comments
 (0)