* @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)
| 2229 | * @return {Object} Instance of given controller. |
| 2230 | */ |
| 2231 | function createControllerDecorator(compileProvider) { |
| 2232 | angular.mock.$ControllerDecorator = ['$delegate', function($delegate) { |
| 2233 | return function(expression, locals, later, ident) { |
| 2234 | if (later && typeof later === 'object') { |
| 2235 | var preAssignBindingsEnabled = compileProvider.preAssignBindingsEnabled(); |
| 2236 | |
| 2237 | var instantiate = $delegate(expression, locals, true, ident); |
| 2238 | if (preAssignBindingsEnabled) { |
| 2239 | angular.extend(instantiate.instance, later); |
| 2240 | } |
| 2241 | |
| 2242 | var instance = instantiate(); |
| 2243 | if (!preAssignBindingsEnabled || instance !== instantiate.instance) { |
| 2244 | angular.extend(instance, later); |
| 2245 | } |
| 2246 | |
| 2247 | return instance; |
| 2248 | } |
| 2249 | return $delegate(expression, locals, later, ident); |
| 2250 | }; |
| 2251 | }]; |
| 2252 | |
| 2253 | return angular.mock.$ControllerDecorator; |
| 2254 | } |
| 2255 | |
| 2256 | /** |
| 2257 | * @ngdoc service |
no test coverage detected