angularjs - UI-Router and Query Parameters in a Redirect -
using angular's ui-router, there way write redirects, such query parameters populated target state. example, here's state:
.state('me.profile', { url: '/profile?action', templateurl: '/app/components/account/profile/profile.html', controller: 'profilectrl', authenticate: true })
specific actions can passing in via query parameter. example:
examplesite.com/profile?action=editprofile
however, wish able provide pretty urls user. example:
examplesite.com/profile/edit
can write redirect statement, populates desired query parameters on route. following code not working, since query param ?action=editpayment
gets lost when user redirected target state.
$urlrouterprovider.when('/profile/edit', '/profile?action=editprofile');
inplace of ?action
change to:
url: '/profile/:action',
inject $stateparams
, read action in controller
var action = $stateparams.action;
Comments
Post a Comment