Is it possible in Angular 2 to restrict a Component
so that it can only appear within a specific parent element on a page? In other words, the Component
should only be allowed if it has a certain parent element. Here is an example:
Allowed:
<parent>
<child></child>
</parent>
Not Allowed: (does not have <parent>
as a parent element)
<child></child>
I want the parent Component
to be transcluded and the <child>
tag to be optional, so I cannot simply do:
@Component({
/*...*/
selector: 'parent',
template: `<child></child>`
});
Any suggestions on how to achieve this?