Search code examples
angulartypescriptcomponents

How can we know if two components are siblings or not?


Hello I am new to angular so I was going through concepts of sharing data between components. I just want someone to clarify me how can one know if two components are siblings. Is it because two components share same module can become siblings and if they are present in different modules they are unsiblings?


Solution

  • Is it because two components share same module can become siblings

    This will depend on usage of component rather than module specific components.

    There are few points that we can consider in this case:

    • We can say if a parent component has more than one child component we can call them as siblings.

    • They need not to be from same module, think you have some imported components from shared module and you can call them along side with current module specific components.

    Example:

        <parent-component> 
           <child-item-one></child-item-one> 
           <child-item-two></child-item-ones> 
        </parent-component>
    

    Hope it clarifies your thoughts about sibling components.