I have some parameters that I need to put to some of my pages, which means when these pages are visited, I want to check if they are in ngrx store or not, and use them if they are. One more rule for this is that if they exist in URL, use them and replace the ones in ngrx store.
So the order is like:
- use the ones from URL if there's any
- use the ones from ngrx store if there's any
- mark them as empty if there's none
I found it's easy to implement with just type script, but I don't know what should I pass as paramters with <a>
element and routerLink.
Is there a way to say when RouterActions.Go
is called, check if there are some parameters already in ngrx store?
Sure there is an easy way. Just make an effects proxy for handling routing actions and use the router just like any other NGRX-effects:
with the router.actions.ts:
and in your component you dispatch router actions on navigation instead of calling routerLink directly in the template:
This way you can also easily go back and forth in your routes.