Skip to content

Instantly share code, notes, and snippets.

@gampleman
Forked from roryf/controller_decorator.js
Last active August 29, 2015 14:08
Show Gist options
  • Save gampleman/63bed7b9f089e00a52a2 to your computer and use it in GitHub Desktop.
Save gampleman/63bed7b9f089e00a52a2 to your computer and use it in GitHub Desktop.
angular.module('ui.router').config(['$provide', function($provide) {
$provide.decorator('$controller', [
'$delegate', '$state',
function($delegate, $state) {
// the `later` and `ident` are private angular variables,
// that break the app if not present
return function(expression, locals, later, ident) {
if ($state.$current) {
locals = _.extend(locals, $state.$current.locals.globals);
}
return $delegate(expression, locals, later, ident);
}
}
]);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment