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

Directives link API documentation did not describe or mention the controller param. #13028

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/content/guide/directive.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,24 @@ want to reuse throughout your app.
In this example we will build a directive that displays the current time.
Once a second, it updates the DOM to reflect the current time.

Directives that want to modify the DOM typically use the `link` option.
`link` takes a function with the following signature, `function link(scope, element, attrs) { ... }`
where:
Directives that want to modify the DOM typically use the `link` option to register DOM listeners
as well as update the DOM. It is executed after the template has been cloned and is where
directive logic will be put.

`link` takes a function with the following signature,
`function link(scope, element, attrs, controller, transcludeFn) { ... }`, where:

* `scope` is an Angular scope object.
* `element` is the jqLite-wrapped element that this directive matches.
* `attrs` is a hash object with key-value pairs of normalized attribute names and their
corresponding attribute values.
* `controller` is the directive's required controller instance(s) or it's own controller (if any).
The exact value depends on the directive's require property.
* `transcludeFn` is a transclude linking function pre-bound to the correct transclusion scope.

<div class="alert alert-info">
For full detail on the `link` method refer to the {@link ng.$compile#-link- `$compile` API} page.
</div>

In our `link` function, we want to update the displayed time once a second, or whenever a user
changes the time formatting string that our directive binds to. We will use the `$interval` service
Expand Down Expand Up @@ -997,7 +1007,7 @@ angular.module('docsTabsExample', [])
scope: {
title: '@'
},
link: function(scope, element, attrs, controllers) {
link: function(scope, element, attrs, controllers, transcludeFn) {
var tabsCtrl = controllers[0],
modelCtrl = controllers[1];

Expand Down