Angular2 - @ViewChild from TypeScript of a base abstract class

I watched @ this SO Q and A and wondered if it is possible to create a base instead abstract class? Instead, is interfaceit possible to have different implementations of the base class in child components that are accessible to the parent component through a decorator @ViewChildin Angular2 ?

Ideally, I would like to have facilities for child components that are created through the parent Routerin order to be able to refer to the parent router - does this make sense? I want the baby to be able to call parentRouter.navigate(["SomeOtherRoute", { args: 'blah' }]);.

My initial approach was for the child components to implement a base class that the parent component would receive the link through the decorator @ViewChild. The parent will subscribeact on the child trying to raise the navigation event, and its handler will call router.navigate(since it has a router at the parent level).

+4
source share
2 answers

You cannot use @ViewChildren()either of these decorators to query subclasses of components.

Only the names of template variables and specific components and directive types are supported (types that are actually created as a component in your view).

+4
source
0

All Articles