長いタイトルのために申し訳ありません。私はngBootstrapとUIRouterを使用しています。Ng2StateDeclaration
のサブクラスを作成しようとしていますが、それは入力して終了するときにngbModal
を開き、閉じます。私は継承なしでこれを簡単に行うことができますが、私はちょっとした解決策をとっています。インターフェイスを実装するTypeScriptクラスを拡張し、親クラスにいくつかの実装を残す方法はありますか?
:
var modalInstance:NgbModalRef;
class ModalStateDeclaration implements Ng2StateDeclaration {
name:string;
url:string;
onEnter(transition: Transition, state: Ng2StateDeclaration) {
modalInstance = modalService.open(SomeComponent);
for (var key in transition.params()) {
modalInstance.componentInstance[key] = transition.params()[key];
}
var currentState = transition.from().name;
modalInstance.result.catch(function(reason) {
if (currentState) {
window.history.back();
} else {
stateService.go('home');
}
});
}
onExit() {
modalInstance.close();
}
}
export const modalBookState:ModalStateDeclaration = {
name: 'modalBookState',
url: '/b/:id'
};
活字体はmodalBookState
がonEnter
とonExit
が欠落していることを私に語っています。 onEnter
とonExit
の実装をModalStateDeclaration
からどのように使用できますか? super()
でそれらを実装する必要がありますか?