ng-redux-route
Usage:
import angular from 'angular';
import ngRoute from 'angular-route';
import { combineReducers } from 'redux';
import ngRedux from 'ng-redux';
import createLogger from 'redux-logger';
import ngReduxRoute, { routeActions, routeReducer } from 'ng-redux-route';
const rootReducer = combineReducers({
router: routeReducer,
});
const app = angular.module('app', [
ngRoute,
ngRedux,
ngReduxRoute,
])
.config(($ngReduxProvider) => {
const logger = createLogger({
level: 'info',
collapsed: true,
});
$ngReduxProvider.createStoreWith(rootReducer, ['ngRouteMiddleware', logger]);
})
.run(($ngRedux) => {
})
.name;
export default app;
setLocation(setters)
$ngRedux.dispatch(routeActions.setLocation([
{ fn: 'search', args: ['company', 1] },
{ fn: 'replace' },
])));
see $location documentation
const mapStateToThis = state => ({
router: state.router,
});
const mapDispatchToThis = ({
setLocation: routeActions.setLocation,
});
const unsubscribe = $ngRedux.connect(mapStateToThis, mapDispatchToThis)(this);
$scope.$on('$destroy', unsubscribe);
this.setLocation([
{ fn: 'url', args: ['/some-url'] },
]);
see ngRedux documentation.
Location Helpers
setUrl(url, [replace = false])
setPath(path, [replace = false])
setSearch(search, [paramValue, replace = false])
setHash(hash, [replace = false])
setState(state, [replace = false])
import { locationHelpers } from 'ng-redux-route';
locationHelpers.setUrl('/some-url', true)