In order to achieve reusability, I have designed two generic components
known as 1)list and 2)details:
Here is a visual representation of the components:
https://i.sstatic.net/NYwZj.png
Now, these components are being reused in other components named SCHOOL and COLLEGE, which will appear as follows:
https://i.sstatic.net/Srbkh.png
Currently,
When a user clicks on a
list-item
(e.g. school 1) from thelist
component within the SCHOOL component, the details of that particular item (e.g. Name, email) should be displayed on the right side (i.e. on the details page/component).Similarly, clicking on a
list-item
(e.g. college 1) from thelist
component within the COLLEGE component should result in showing the specific item details (e.g. Name, email) on the right side (i.e. on the details page/component).
I found a solution to this issue through this question. This example involves communication between components using services
. However, my challenge lies in reusing the component. How can I implement services
when reusing components?
Check out the Stackblitz DEMO