recently started Angular2, came across the below scenario
where need to access the element from a sibling component, but not from Parent Cmp. Thanks for looking at it
Example:
Let's say we have component A and component B which are on same level.
Need the iframe element in templateA in ComponentB to Hide or
delete the element.
index.html
<component-A> </component-A>
<component-B> </component-B>
ComponentA.html
<div>
<iframe id="someIframe"></iframe>
</div>
ComponentB.html
<div>
<form id="someForm"></form>
</div>
@component
({
selector:'component-A',
templateUrl:'/componentA.html'
})
constructor() {
}
@component
({
selector:'component-B',
templateUrl:'/componentB.html'
})
constructor() {
//need to get hold of the iframe element to hide that.
}