Transferring data between components without @ Input / @ Output

In short, I need a "shopping cart" as a ratio from one component to the rest of the site. I say "shopping basket" because it is basically a list of needs created by the user when viewing them. It will not have any prices or tax logic, but each type of need will have its own sub-parametersunique from the others, which I am in the process of creating interfacesfor. I figured I needs componentwould use types anyto accept incoming pieces of data.

Nowadays, creating massive highways @Inputsand @Outputsacross an entire tree just to go through one branch and return down a level seems overly tedious. I thought it would be nice if I could create a function that pushes directly to needs componentor can create a class to push everything and subscribe to it in needs component.

I set the filter in my search until February 1 - now I found this Exchange data between components using a service in Angular2

He sheds a little more light on the possibility that this is possible, but since I don’t know how I should do it, I don’t know how to get an answer.

I did not come up with any code to try it, because I do not know what to do, so all I have is my components. Seeing that I am asking about a way to create relationships that work no matter where things fall on the component tree, I don’t see the point in placing components that basically only say <h1>hi</h1>to show that they work. If you still want to see my code, I will publish it, but it is not so much. I am still using Angular2 and cannot upgrade Node and NPM to use 4 at the moment. Any information on how to achieve this would be greatly appreciated.

+4
source share
1 answer

Angular , , , , , ngrx , ngrx , .

, https://github.com/rahulrsingh09/AngularConcepts

+2

Source: https://habr.com/ru/post/1676286/


All Articles