Sync Angular router state with redux, including: current path, current url, query params, route params, fragment, previous route.
npm install @district01/ng-redux-router@3.1.2
Sync Angular Router state with the Redux app state, gaining easy access to the entire route, not just the activated route.
@angular/router
npm install @district01/ng-redux-router --save
Import component in app.module.ts:
import { NgReduxRouterModule } from 'ng-redux-router';
@NgModule({
imports: [
NgReduxRouterModule
]
})
export class AppModule {}
Initialize ReduxRouter
with a dispatch function (e.g. using the @angular-redux/store
package:
constructor(
private ngRedux: NgRedux<MyAppState>,
private ngReduxRouter: NgReduxRouter
) {
ngReduxRouter.initialize(ngRedux.dispatch);
}
The ReduxRouter
will listen for route changes and store the current, previous and active (pending) route in the state. The following properties are stored for each route:
The ROUTE_UPDATE
action will only be dispatched once the NavigationEnd
event is triggered.