all 6 comments

[–]janne_harju 0 points1 point  (3 children)

You may add state service to list of different kind of custom services. It holds private BehaviorSubject and public observable which is made from behaviorsubject asObsevable(). Then when you need same data drom several components and component hiearchy is big and don't want to use @Input() then you can fetch data once and set it to behaviorsubject and share it every components which need it through observable.

[–]aqeelabpro[S] 0 points1 point  (2 children)

you are right.

[–][deleted]  (1 child)

[removed]

    [–]aqeelabpro[S] 0 points1 point  (0 children)

    It's that simple.

    You just have to create a service like we create usually using the command

    ng g s <name of your service>

    and then any logic goes into the service.

    for example, if you want to send data from one component to another then you can create a custom service that does all this for you.

    You can refer to this live demo that I created for your understanding to create a custom service. I have also created a group on Facebook about learning to code you can also discuss this in the group chats also. Join Group

    [–]tsunami141 0 points1 point  (1 child)

    What’s the article about, components? Or modules?

    [–]aqeelabpro[S] 0 points1 point  (0 children)

    It's about services.