【发布时间】:2016-07-14 01:26:43
【问题描述】:
我正在尝试使用以下内容覆盖路由器上的 deactive 方法:
导出类 AnimationRouterOutlet 扩展 RouterOutlet { 公共路线:任何; private parentRouter:路由器;
constructor(_elementRef: ElementRef, _loader: DynamicComponentLoader,
_parentRouter: Router, @Attribute('name') nameAttr: string) {
super(_elementRef, _loader, _parentRouter, nameAttr);
this.parentRouter = _parentRouter;
}
deactivate(instruction: ComponentInstruction){
setTimeout(()=>{
console.log("deactivvated state");
return super.deactivate(instruction);
},1000);
}
activate(instruction: ComponentInstruction) {
console.log(instruction);
return super.activate(instruction);
}
}
如您所见,我正在尝试在更改网页时造成延迟 - 这样我就可以创建一些动画。
但是,使用这个,我有 TypeScript 编译器错误:
:错误 TS2415:“AnimationRouterOutlet”类错误地扩展了基础 类'RouterOutlet'。属性“停用”的类型是 不相容。 类型 '(instruction: ComponentInstruction) => void' 不可分配给类型 '(nextInstruction: ComponentInstruction) => 承诺'。 类型 'void' 不能分配给类型 'Promise'。
我该如何解决这个问题?
【问题讨论】:
标签: typescript angular