I canβt say from your question what you are really looking for, but you can try to create your own directive (a modified version of the ngController directive ) may indicate injections for the controller:
app.directive('myController', function($controller) { return { scope: true, link: function(scope, elem, attrs) { var locals = scope.$eval(attrs.locals); angular.extend(locals, {$scope: scope}); $controller(attrs.myController, locals); } }; });
You would use it something like this:
<div my-controller='MainController' locals='{x: "test", y: 42}'></div>
Here's a JsFiddle demonstrating the technique: http://jsfiddle.net/BinaryMuse/qBZZk/
source share