File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -2232,12 +2232,21 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
2232
2232
* @ngdoc service
2233
2233
* @name $componentController
2234
2234
* @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
+ *
2237
2237
* Be aware that the controller will be instantiated and attached to the scope as specified in
2238
2238
* the component definition object. If you do not provide a `$scope` object in the `locals` param
2239
2239
* 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
+ *
2241
2250
* @param {string } componentName the name of the component whose controller we want to instantiate
2242
2251
* @param {Object } locals Injection locals for Controller.
2243
2252
* @param {Object= } bindings Properties to add to the controller before invoking the constructor. This is used
You can’t perform that action at this time.
0 commit comments