Skip to content

Commit c1e140a

Browse files
committed
docs($compile): add docs for bindToController with object hash
Closes angular#13228 Closes angular#13625 Closes angular#13658 Closes angular#13681
1 parent 0e03644 commit c1e140a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ng/compile.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,23 @@
212212
*
213213
*
214214
* #### `bindToController`
215-
* When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will
215+
* This property is used to bind scope properties directly to the controller. It can be either
216+
* `true` or an object hash with the same format as the `scope` property. Additionally, a controller
217+
* alias must be set, either by using `controllerAs: 'myAlias'` or by specifying the alias in the controller
218+
* definition: `controller: 'myCtrl as myAlias'`.
219+
*
220+
* When an isolate scope is used for a directive (see above), `bindToController: true` will
216221
* allow a component to have its properties bound to the controller, rather than to scope. When the controller
217222
* is instantiated, the initial values of the isolate scope bindings are already available.
218223
*
224+
* It is also possible to set `bindToController` to an object hash with the same format as the `scope` property.
225+
* This will set up the scope bindings to the controller directly. Note that `scope` can still be used
226+
* to define which kind of scope is created. By default, no scope is created. Use `scope: {}` to create an isolate
227+
* scope (useful for component directives).
228+
*
229+
* If both `bindToController` and `scope` are defined and have object hashes, `bindToController` overrides `scope`.
230+
*
231+
*
219232
* #### `controller`
220233
* Controller constructor function. The controller is instantiated before the
221234
* pre-linking phase and can be accessed by other directives (see

0 commit comments

Comments
 (0)