From the course: Angular State Management with NgRx
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Component architecture in action - Angular Tutorial
From the course: Angular State Management with NgRx
Component architecture in action
- [Instructor] Okay, so let's now implement our recommended component architecture with NgRx. So the first thing to do is that we're going to change a zip code entry component. This component has some business logic in it. It's aware that we have a store and about dispatching action. So we want to remove this and basically going to cut to that code from zip code entry component and move it to the main.page.component.ts right there. So pasting it in main page component. And now our zip code entry component is going to just emit an event. So we're going to have a zipAdded property, which is going to be an output, and what we output is a string. And the idea is that when we add a new zip code, all we do is emit that zip code to the parent. So we don't know, the component is not aware of what must be done with that zip code. It just says, okay, someone wants to add the zip, I'm going to emit that event to the parent container component. So here what we do now is zipAdded.emit of that…