Skip to content

Instantly share code, notes, and snippets.

@RodolpheGohard
Created February 19, 2016 16:46
Show Gist options
  • Save RodolpheGohard/20c178cfec15820d106a to your computer and use it in GitHub Desktop.
Save RodolpheGohard/20c178cfec15820d106a to your computer and use it in GitHub Desktop.
angular.module('ngControllerLocals',[]).config(function ($provide) {
$provide.decorator('ngControllerDirective', function ($delegate, $parse, $controller) {
var directive = $delegate[0];
directive.controller = function controllerWrapperForLocals($scope, $attrs, $element, $transclude) {
var ngController = $attrs.ngController;
var locals = {
$scope: $scope,
$attrs: $attrs,
$element: $element,
$transclude: $transclude
};
angular.extend(locals, $parse($attrs.ngControllerLocals )($scope));
return $controller(ngController, locals, false, directive.controllerAs);
};
return $delegate;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment