I've got project in AngularJS and I have baseController and child controller inheriting from it.
class BaseController {
constructor($log, $state) {
'ngInject';
this.$log = $log;
this.$state = $state;
}
}
class ChildController extends BaseController {
constructor(myService) {
'ngInject';
super();
this.myService = myService;
}
}
My question is: Do I need to inject all parent dependency injections into child controller even when I am not using it?
Above example shows what I want to achieve, but it's not working. Anyone got idea if I can achieve it without passing BaseController services into super($scope, $state) invocation?
super($scope,$state)?BaseController, which already have these injected. Seems redundant to me. For now I didsuper($scope, $state), but I want to know if is there a better way? doing it for 2 injections is ok, but when I have ~7 or more it is a bit of work to correct DI in parent and every child class.$scope. Common functions should be moved to services instead of extending controller classes.AuthenticationService).