Extend a component using I / O

Is it possible to extend a component in Angular 2 and still use the inputs and outputs in the parent?

export class Book { @Input() name; } export class EBook extends Book { @Input() downloadUrl; @Input() size; } 

When I try to extend a component, everything inside the class works, except for code that needs attributes / decorators like inputs and outputs. I made a plunker that illustrates the problem: http://plnkr.co/edit/cfTKgScbaXMmEMEMOGY0zr

A book is a basic component with a single I / O name.

EBook inherits the book and adds input / output DownloadUrl, Size.

As you can see in the plunker, EBook does not receive a name, because the input is defined in the book and not in EBook

+5
source share
1 answer

as for rc4, input decorators are only inherited if the subclass does not have input decorators themselves. otherwise you must copy all ads.

its a known problem you can trace here: https://github.com/angular/angular/issues/5415

+4
source

Source: https://habr.com/ru/post/1237098/


All Articles