Created
December 11, 2013 10:29
-
-
Save roryf/7908187 to your computer and use it in GitHub Desktop.
Proof of concept to allow ui-router resolvers to also apply when controllers are created via ng-controller directive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('ui.router').config(['$provide', function($provide) { | |
$provide.decorator('$controller', [ | |
'$delegate', '$state', | |
function($delegate, $state) { | |
return function(expression, locals) { | |
if ($state.$current) { | |
locals = _.extend(locals, $state.$current.locals.globals); | |
} | |
return $delegate(expression, locals); | |
} | |
} | |
]); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems to have stopped working with Angular 1.3. I filed an issue about it, for now there is a fix:
https://gist.github.com/gampleman/63bed7b9f089e00a52a2