When writing controllers using Type.prototype.method = function() {} to
define methods. I've found that accessing the injected services requires a
lot of boilerplate. Its the main reason i havent yet adpoted 'Controller
as' syntax.So i was thinking that we could store them on the object in an automated fashion: http://plnkr.co/edit/YjrcGcScU4m6mUq8DkKm For controllers with a lot of dependancies this will turn : function MyController($rootScope, $scope, People, MyType, AnotherType, Manager, Something) { this.$rootScope = $rootscope; this.$scope = $scope; this.People = People; this.MyType = MyType; this.AnotherType = AnotherType; this.Manager = Manager; this.Something = Something; } MyController.prototype.myMethod = function() { this.$rootScope.test = 123; } into function MyController($rootScope, $scope, People, MyType, AnotherType, Manager, Something, $args) { this.services = $args(MyController, arguments); } MyController.prototype.myMethod = function() { this.services.$rootScope.test = 123; } Does anyone see any issues with this approach (its totally untested) ? Is there an easier way using the $inejector or something? Is this a good idea? I think it will help people using TypeScript too. cheers -- Tony Polinelli -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
