Skip to content

Instantly share code, notes, and snippets.

@roryf
Created December 11, 2013 10:29
Show Gist options
  • Save roryf/7908187 to your computer and use it in GitHub Desktop.
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.
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);
}
}
]);
}]);
@gampleman
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment