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

Commit fc25a44

Browse files
chrisnicolapetebacondarwin
authored andcommitted
docs(guide:directive): add directive controller usage
Specifically adding a directive controller to the example definition and how to use declare injectables to avoid minification errors.
1 parent d6984db commit fc25a44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/content/guide/directive.ngdoc

+7
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ Here's an example directive declared with a Directive Definition Object:
269269
transclude: false,
270270
restrict: 'A',
271271
scope: false,
272+
controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
272273
compile: function compile(tElement, tAttrs, transclude) {
273274
return {
274275
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
@@ -392,6 +393,12 @@ compiler}. The attributes are:
392393
* `$transclude` - A transclude linking function pre-bound to the correct transclusion scope:
393394
`function(cloneLinkingFn)`.
394395

396+
To avoid errors after minification the bracket notation should be used:
397+
398+
<pre>
399+
controller: ['$scope', '$element', '$attrs', '$transclude', function($scope, $element, $attrs, $transclude) { ... }]
400+
</pre>
401+
395402
* `require` - Require another controller be passed into current directive linking function. The
396403
`require` takes a name of the directive controller to pass in. If no such controller can be
397404
found an error is raised. The name can be prefixed with:

0 commit comments

Comments
 (0)