MCPcopy Index your code
hub / github.com/angular-ui/ui-router / createControllerDecorator

Function createControllerDecorator

test/angular/1.5/angular-mocks.js:2231–2254  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

2229 * @return {Object} Instance of given controller.
2230 */
2231function 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

Callers 1

angular-mocks.jsFile · 0.70

Calls 1

instantiateFunction · 0.70

Tested by

no test coverage detected