I was looking @ this SO Q & A, and wondering if it was possible to have a base abstract class
instead? Rather than an interface
, is it possible to have differing implementations of a base class in child components that are accessible to the parent component via the @ViewChild
decorator in Angular2?
Ideally, I would like to have a means for child components that are instantiated via a parent Router
to be capable of invoking the parent router -- does that make sense? I want the child to be able to call parentRouter.navigate(["SomeOtherRoute", { args: 'blah' }]);
.
My initial approach was to have the child components implement a base class that the parent component would get a reference to via the @ViewChild
decorator. The parent would subscribe
to the action of the child attempting to invoke a navigation event, and its handler would invoke the router.navigate
(since it has the router at the parent level).