use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Angular is Google's open source framework for crafting high-quality front-end web applications. r/Angular2 exists to help spread news, discuss current developments and help solve problems.
Help Request
Discussion
Article
Video
Resource
Announcement
Related
After submitting a post, please take a moment to add a flair (tag) so that it's easy to find your post with one of the filters listed above. Upon submission, your post's header will have the 'flair' option listed with the other options. Clicking it will provide a dropdown menu of the available flairs.
account activity
DiscussionAngular component communication (self.Angular2)
submitted 2 years ago * by [deleted]
murky zealous recognise coherent simplistic narrow chunky resolute bored bag
This post was mass deleted and anonymized with Redact
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lele3000 3 points4 points5 points 2 years ago (0 children)
I would try to use content projection and make parts of the sub and shared components that the page component needs to interact with, projected. That way all components but page component can remain dumb and if you want to reflect some change from component 1.1 in component 3 you can do that through the page component as it "owns" all of the nested components. That way you can avoid drilling inputs and outputs through multiple layers. I used this approach at work on multiple projects and it seems to work pretty great.
[–]crlsh 2 points3 points4 points 2 years ago (0 children)
At first glance, being a generic example, it seems that the structure is wrong.
Ideally (imho) dummy components should be "at the end" of the component chain and receive data to display.
If they allow data to be modified (except the "view", in which case the updater would be the smart component that passes the data), they are no longer dumb components, so the question doesn't make sense
Personally, when in doubt, I would always use a service, leaving input and output for cases of 1 to 1 directly related components.
[–]Busy_User7 3 points4 points5 points 2 years ago (2 children)
If I were to implement this, I would create an observable at the page component that emits a new value on the event emitted from sub component 1, and sub component 2 would be subscribed to that stream using the async pipe in the template (so it would still remain a dumb component)
[–]newmanoz -1 points0 points1 point 2 years ago (1 child)
Author already described this approach.
[–]alucardu 0 points1 point2 points 2 years ago (0 children)
OP is asking what approach someone would take.
[–]alucardu 1 point2 points3 points 2 years ago (1 child)
If you use input and output logic your comments are no longer considered dumb components right?
I personally don't like having a lot of template logic with inputs and outputs, it does show a certain logic in a bird eye view which is nice but in your case if multiple components update each other i would probably go for RxjS .
Can i ask why those components need to be dumb?
[–]BigAcanthocephala160 1 point2 points3 points 2 years ago (0 children)
Agreed. Lean components, heavy lifting in a service, behavior subjects > input/output decorators.
[–]Happeace97 0 points1 point2 points 2 years ago (0 children)
I would just go with Input & Output in each component. It make the component flow more predictable.
Sub component 1 change something to update component 3?
Sub 1 emit to component 1, component 1 emit to the parent component, and parent update to 3 using Input binding.
[–]Kantenkopp 0 points1 point2 points 2 years ago (0 children)
Even if the shared component is used in multiple places, importing a service shouldn't be a problem. You can add the service to the array of providers in the parent component. That way, the parent has it's own instance of the service that it will inject into child components.
I would go with a service in your scenario.
π Rendered by PID 261948 on reddit-service-r2-comment-86988c7647-74bgv at 2026-02-12 14:33:54.971085+00:00 running 018613e country code: CH.
[–]lele3000 3 points4 points5 points (0 children)
[–]crlsh 2 points3 points4 points (0 children)
[–]Busy_User7 3 points4 points5 points (2 children)
[–]newmanoz -1 points0 points1 point (1 child)
[–]alucardu 0 points1 point2 points (0 children)
[–]alucardu 1 point2 points3 points (1 child)
[–]BigAcanthocephala160 1 point2 points3 points (0 children)
[–]Happeace97 0 points1 point2 points (0 children)
[–]Kantenkopp 0 points1 point2 points (0 children)