In a nutshell, I need a "shopping cart" like relationship from one component to the rest of the site. I say "shopping cart like" because it's basically a list of needs generated by the user as they browse. It won't have any prices or tax logic, but each type of need will have its' own sub-parameters
unique from the others which I'm in the midst of creating interfaces
for. I figured the needs component
would use types of any
to accept the incoming chunks of data.
As of right now creating massive highways of @Inputs
and @Outputs
through the entire tree just to go over one branch and back down a tier seems excessively tedious. I figured it would be good if I could create a function that pushes directly to the needs component
or maybe create a class to push everything to and make a subscription to it in the needs component
.
I set a filter on my search to February 1st - now and found this
Share data between components using a service in Angular2
It sheds a little more light on the fact that it's possible, but as I don't know how I should go about this I don't know how to derive an answer out of it.
I haven't come up with any code for attempting it because I don't know what to attempt so all I have is my components. Seeing that I'm asking about a way to create a relationship that works no matter where things fall on the component tree I don't see any point in posting components that basically only say <h1>hi</h1>
so far to show they're working. If you'd still like to see my code I'll post it, but it isn't much lol. I'm still using Angular2 and can't update Node and NPM to use 4 at the moment. Any info on how to achieve this would be greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…