* @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)
| 2294 | * @return {Object} Instance of given controller. |
| 2295 | */ |
| 2296 | function createControllerDecorator(compileProvider) { |
| 2297 | angular.mock.$ControllerDecorator = ['$delegate', function($delegate) { |
| 2298 | return function(expression, locals, later, ident) { |
| 2299 | if (later && typeof later === 'object') { |
| 2300 | var preAssignBindingsEnabled = compileProvider.preAssignBindingsEnabled(); |
| 2301 | |
| 2302 | var instantiate = $delegate(expression, locals, true, ident); |
| 2303 | if (preAssignBindingsEnabled) { |
| 2304 | angular.extend(instantiate.instance, later); |
| 2305 | } |
| 2306 | |
| 2307 | var instance = instantiate(); |
| 2308 | if (!preAssignBindingsEnabled || instance !== instantiate.instance) { |
| 2309 | angular.extend(instance, later); |
| 2310 | } |
| 2311 | |
| 2312 | return instance; |
| 2313 | } |
| 2314 | return $delegate(expression, locals, later, ident); |
| 2315 | }; |
| 2316 | }]; |
| 2317 | |
| 2318 | return angular.mock.$ControllerDecorator; |
| 2319 | } |
| 2320 | |
| 2321 | /** |
| 2322 | * @ngdoc service |
no test coverage detected