いくつかのモジュールを注入したい親クラスがあり、次にこれらの注入されたモジュールを使用したいいくつかの派生クラスがあります。ただし、派生クラスではsuper()
パラメーターなしで呼び出す必要があるため、親クラスに挿入されたモジュールは未定義です。これはどのように行うことができますか?
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';
@inject (HttpClient)
export class Parent{
constructor(module){
//this constructor is called from derived class without parameters,
//so 'module' is undefined !!
this.injectedmodule = module;
}
}
export class ClassA extends Parent{
constructor(){
super();
this.injectedmodule.get() // injectedmodule is null !!!
}
}