Currently, I am facing an issue with creating a child class ModalCtrlChild extends ModalCtrl
from my controller class ModalCtrl
. Whenever I attempt to do this, I encounter an unknown provider error related to the modules injected in ModalCtrl
.
The project was built using this generator that utilizes NgInject for dependency injection, which I suspect is causing the problem.
Here is a snippet of my code:
export default class ModalCtrl {
static get UID(){
return "ModalCtrl"
}
... // all my ModalCtrl methods here
/* @ngInject */
constructor(ngDialog, PreoModalType, OutletService, $q, $timeout, VenueService) {
"ngInject";
... // ModalCtrl constructor logic initing variables
}
}
And here is the child class:
import ModalCtrl from '../../preoModal.controller';
export default class ModalCtrlChild extends ModalCtrl{
static get UID(){
return "modalCtrlChild"
}
/* @ngInject */
constructor() {
// "ngInject";
console.log("in super constructor");
super();
}
}
However, this setup results in the following error:
Error: [$injector:modulerr] Failed to instantiate module function ModalCtrlChild() due to:
Error: [$injector:unpr] Unknown provider: ngDialog
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=ngDialog
While ngDialog is confirmed to be imported and functioning correctly. If I remove extends ModalCtrl
from ModalCtrlChild, the code runs without errors but loses the necessary inheritance. Any suggestions would be greatly appreciated.
EDIT
Prior to posting this question, I have tried various solutions suggested by others but the issue persists, indicating that the problem lies with the child class injections rather than the parent class injections.
One suggestion I attempted was:
- Removing annotations and dependencies from ModalCtrlChild
- Removing annotations and dependencies from ModalCtrl while leaving them in the child
However, this resulted in the exact same error message:
Error: [$injector:modulerr] Failed to instantiate module function PreoModalController_Form() due to:
Error: [$injector:unpr] Unknown provider: ngDialog
My suspicion is that babel's construction of the extended class might be interfering with ngInject's functionality. I am exploring options for manual injections to potentially resolve this issue and confirm that babel may be the root cause.