@query does not work on inherited classes

Suppose I have: ConcreteClass extends BaseClass {}

When trying to use @Query (BaseClass) Angular did not find anything. Only when I request ConcreteClass do I get results; any idea?

0
source share
1 answer

Subclassing in @ViewChild(SubClass) not supported.

See https://github.com/angular/angular/issues/1828

Workaround is explained in https://github.com/angular/angular/issues/8580#issuecomment-218525425

 @Component({ selector: 'my-fancy-item', providers: [{provide: MyItem, useExisting: MyFancyItem}] }) class MyFancyItem extends MyItem {} 

which makes a request for MyItem , searches for MyItem and MyFancyItem . I have not tried, though.

+1
source

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


All Articles