ERROR TypeError: Cannot read property 'ngInjectableDef' of undefined
Angular Dependency Injection system only extracts/resolves dependency for a class on which
Injectable
decorator is written. You've to handle other stuff by your own.
DummyAbstract
constructor has constructor with TestService
dependency, and when you extend using ThisChild
provider, you haven't had passed TestService
to the constructor of an DummyAbstract
. Whenever you have such case you have to pass dependencies explicitly to the parent class using super
method to call base class constructor.
export class ThisChild extends DummyAbstract {
constructor(testService: TestService) { // no private or public
super(testService); //calling base class constructor with dependency.
}
thisisimp() {
return 'text';
}
}
Since there is not much google search result for this problem I will provide my solution for it here (not related to this particular problem but with same error message). So basically i get this problem as well: ERROR TypeError: Cannot read property 'ngInjectableDef' of undefined Nothing has been changed in a code before and after the error start to appears. All i had to do was remove node_module folder, flush node cache and reinstall it and it started to work. It was related to some angular material changes as far as I know.