Nitesh Kumar Nitesh Kumar - 1 year ago 66
AngularJS Question

how to set dynamic state based on forgot password email

I am sending below url to user for forgot-passwor:


How to get auth (string after /reset-password/) value and use that in state?

In my app.js file I want to have url of state to be dynamic and redirect user to reset-password page like below:

$stateProvider.state('reset-password', {
url: '/reset-password/:token',
templateUrl: '/home/login/views/prtl_resetPassword.html'

When I load the page, I am redirected to login page. I can understand that token is not assigned which was sent to user eamil. What is the best solution for this?

Answer Source

The value from the URL fragment :token is used to populate $stateParams, which can be injected into a controller.

You can create a controller for the reset-password state. Inside the controller, you can take the token value from $stateParams and pass it on to the login state with $state.go().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download