I want to get and set the object data in different component in angular.
So which is the best way to do that?
I want to get and set the object data in different component in angular.
So which is the best way to do that?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anupam MaitiRank #295 · 8.5K reputationPosted Feb 1, 2023, 7:49 AM EST
There are multiple ways we can share data between components, like -
1. Using Input and Output decorators where parent-child component relationship are there.
2. Using NgRx module where centralize data store for sharing data and state management are needed.
3. Using shared service to hold data in a single place and allow components to subscribe to that data
So, Best method will be specific to use cases.
Aman GuptaRank #193 · 12.4K reputationPosted Feb 1, 2023, 11:24 AM EST
Data Sharing Between Angular Components
Parent to Child: via Input
Child to Parent: via Output() and EventEmitter
Child to Parent: via ViewChild
Unrelated Components: via a Service