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 2 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
9 changes: 5 additions & 4 deletions docs/content/guide/directive.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,15 @@ 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, which is documented on the {@link ng.$compile `$compile` API} page.
`link` takes a function with the following signature, `function link(scope, element, attrs, controller, transcludeFn) { ... }`, where:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, wrap lines at 100 chars max.


* `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 controller for the directive, if defined.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not 100% accurate. Based on the $compile API docs, I would suggest something like this:

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:

  • no controller(s) required: the directive's own controller, or undefined if it doesn't have one
  • string: the controller instance
  • array: array of controller instances

* `transcludeFn` is a transclude linking function pre-bound to the correct translusion scope.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translusion --> transclusion


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 +998,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