diff --git a/src/state.js b/src/state.js index 51c55ee63..29d303a52 100644 --- a/src/state.js +++ b/src/state.js @@ -1394,7 +1394,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { promises.push($resolve.resolve(injectables, locals, dst.resolve, state).then(function (result) { // References to the controller (only instantiated at link time) if (isFunction(view.controllerProvider) || isArray(view.controllerProvider)) { - var injectLocals = angular.extend({}, injectables, locals); + var injectLocals = angular.extend({}, injectables, locals, result); result.$$controller = $injector.invoke(view.controllerProvider, null, injectLocals); } else { result.$$controller = view.controller; diff --git a/test/stateSpec.js b/test/stateSpec.js index 6880fac49..fa778c3fe 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -70,9 +70,12 @@ describe('state', function () { .state('dynamicController', { url: "/dynamic/:type", template: "test", - controllerProvider: function($stateParams) { - ctrlName = $stateParams.type + "Controller"; + controllerProvider: function($stateParams, foo) { + ctrlName = $stateParams.type + foo + "Controller"; return ctrlName; + }, + resolve: { + foo: function() { return 'Foo'; } } }) .state('home.redirect', { @@ -484,7 +487,7 @@ describe('state', function () { it('uses the controllerProvider to get controller dynamically', inject(function ($state, $q) { $state.transitionTo('dynamicController', { type: "Acme" }); $q.flush(); - expect(ctrlName).toEqual("AcmeController"); + expect(ctrlName).toEqual("AcmeFooController"); })); });