我想为我的组件定义一个基类来共享一些功能.所以我开始:
export abstract class BaseComponent {
protected getName(): string;
}
@Component(...)
export class MyComponent extends BaseComponent {
protected getName(): string {
return "MyComponent";
}
}
Run Code Online (Sandbox Code Playgroud)
但是在我需要为BaseComponent添加一些注释之后@HostListener('window:keydown', ['$event']).所以,我不得不添加@Component到BaseComponent启用角度注释.一切都很好......直到我试图在生产模式下编译
ng build --prod
:
无法确定类BaseComponent的模块
所以我加入BaseComponent了@NgModule,但我有:
没有为组件BaseComponent指定模板
所以我补充说
@Component({template: ''})
Run Code Online (Sandbox Code Playgroud)
但我有 :
"typeof BaseComponent"类型的参数不能分配给"Type"类型的参数.无法将抽象构造函数类型分配给非抽象构造函数类型.
所以我删除了" abstract"关键字,以便在生产模式下编译我的项目.
你有解决方案吗?我不喜欢错误的观念!
我想绘制一个椭圆形,但我希望能够旋转它.我知道我可以使用canvas.drawOval(...)和canvas.rotate(...).但是,我想旋转我的椭圆而不是整个画布; 也就是说,我想先将椭圆旋转到画布上.我在绘制之前通过操纵坐标成功地旋转了一个矩形,但这种方法对我来说不适用于椭圆形.
abstract ×1
android ×1
angular ×1
canvas ×1
components ×1
inheritance ×1
rotation ×1
typescript ×1