This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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 @@ -2257,12 +2257,21 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
2257
2257
* @ngdoc service
2258
2258
* @name $componentController
2259
2259
* @description
2260
- * A service that can be used to create instances of component controllers.
2261
- * <div class="alert alert-info">
2260
+ * A service that can be used to create instances of component controllers. Useful for unit-testing.
2261
+ *
2262
2262
* Be aware that the controller will be instantiated and attached to the scope as specified in
2263
2263
* the component definition object. If you do not provide a `$scope` object in the `locals` param
2264
2264
* then the helper will create a new isolated scope as a child of `$rootScope`.
2265
- * </div>
2265
+ *
2266
+ * If you are using `$element` or `$attrs` in the controller, make sure to provide them as `locals`.
2267
+ * The `$element` must be a jqLite-wrapped DOM element, and `$attrs` should be an object that
2268
+ * has all properties / functions that you are using in the controller. If this is getting too complex,
2269
+ * you should compile the component instead and access the component's controller via the
2270
+ * {@link angular.element#methods `controller`} function.
2271
+ *
2272
+ * See also the section on {@link guide/component#unit-testing-component-controllers unit-testing component controllers}
2273
+ * in the guide.
2274
+ *
2266
2275
* @param {string } componentName the name of the component whose controller we want to instantiate
2267
2276
* @param {Object } locals Injection locals for Controller.
2268
2277
* @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