* @ngdoc service * @name $controller * @description * A decorator for ng.$controller with additional `bindings` parameter, useful when testing * controllers of directives that use $compile#-bindtocontroller- `bindToController`. * * Depending on the value of * {@link ng.$compil
(compileProvider)
| 2302 | * @return {Object} Instance of given controller. |
| 2303 | */ |
| 2304 | function createControllerDecorator(compileProvider) { |
| 2305 | angular.mock.$ControllerDecorator = ['$delegate', function($delegate) { |
| 2306 | return function(expression, locals, later, ident) { |
| 2307 | if (later && typeof later === 'object') { |
| 2308 | var preAssignBindingsEnabled = compileProvider.preAssignBindingsEnabled(); |
| 2309 | |
| 2310 | var instantiate = $delegate(expression, locals, true, ident); |
| 2311 | if (preAssignBindingsEnabled) { |
| 2312 | angular.extend(instantiate.instance, later); |
| 2313 | } |
| 2314 | |
| 2315 | var instance = instantiate(); |
| 2316 | if (!preAssignBindingsEnabled || instance !== instantiate.instance) { |
| 2317 | angular.extend(instance, later); |
| 2318 | } |
| 2319 | |
| 2320 | return instance; |
| 2321 | } |
| 2322 | return $delegate(expression, locals, later, ident); |
| 2323 | }; |
| 2324 | }]; |
| 2325 | |
| 2326 | return angular.mock.$ControllerDecorator; |
| 2327 | } |
| 2328 | |
| 2329 | /** |
| 2330 | * @ngdoc service |
no test coverage detected