Skip to content

Commit 4dba7b0

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 d3cd3c0 commit 4dba7b0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/content/guide/directive.ngdoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ Here's an example directive declared with a Directive Definition Object:
244244
transclude: false,
245245
restrict: 'A',
246246
scope: false,
247+
controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
247248
compile: function compile(tElement, tAttrs, transclude) {
248249
return {
249250
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
@@ -365,6 +366,12 @@ compiler}. The attributes are:
365366
* `$transclude` - A transclude linking function pre-bound to the correct transclusion scope:
366367
`function(cloneLinkingFn)`.
367368

369+
To avoid errors after minification the bracket notation should be used:
370+
371+
<pre>
372+
controller: ['$scope', '$element', '$attrs', '$transclude', function($scope, $element, $attrs, $transclude) { ... }]
373+
</pre>
374+
368375
* `require` - Require another controller be passed into current directive linking function. The
369376
`require` takes a name of the directive controller to pass in. If no such controller can be
370377
found an error is raised. The name can be prefixed with:

0 commit comments

Comments
 (0)