Skip to content

Commit fe1166f

Browse files
Narretzpetebacondarwin
authored andcommitted
docs($componentController): add more info
1 parent 910878e commit fe1166f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ngMock/angular-mocks.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -2232,12 +2232,21 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
22322232
* @ngdoc service
22332233
* @name $componentController
22342234
* @description
2235-
* A service that can be used to create instances of component controllers.
2236-
* <div class="alert alert-info">
2235+
* A service that can be used to create instances of component controllers. Useful for unit-testing.
2236+
*
22372237
* Be aware that the controller will be instantiated and attached to the scope as specified in
22382238
* the component definition object. If you do not provide a `$scope` object in the `locals` param
22392239
* then the helper will create a new isolated scope as a child of `$rootScope`.
2240-
* </div>
2240+
*
2241+
* If you are using `$element` or `$attrs` in the controller, make sure to provide them as `locals`.
2242+
* The `$element` must be a jqLite-wrapped DOM element, and `$attrs` should be an object that
2243+
* has all properties / functions that you are using in the controller. If this is getting too complex,
2244+
* you should compile the component instead and access the component's controller via the
2245+
* {@link angular.element#methods `controller`} function.
2246+
*
2247+
* See also the section on {@link guide/component#unit-testing-component-controllers unit-testing component controllers}
2248+
* in the guide.
2249+
*
22412250
* @param {string} componentName the name of the component whose controller we want to instantiate
22422251
* @param {Object} locals Injection locals for Controller.
22432252
* @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used

0 commit comments

Comments
 (0)