1

In my app if I receive password reset instructions I go to server with url like:

/changepass?key=1231231231212312

in controller I have such code:

  if (typeof $routeParams.key !== 'undefined') {
    $scope.changePassword();
  }

but when I change password and want to login in same view, I go to another location, but this ?key=123123123 is still there. What did I do wrong, and how to go to empty: /company without any keys?

$scope.login = function() {
        ***
                $location.path('/company');
                ***
      };

also I tried $scope.$apply($location.path('/company')); but still when I go to company after login I have params in url. How to solve this?

In routing:

    .when('/signin', {
        templateUrl: 'views/authorization.html',
        controller: 'AuthorizationCtrl'
    })
    .when('/changepass', {
        templateUrl: 'views/authorization.html',
        controller: 'AuthorizationCtrl'
    })

1 Answer 1

1

There are two ways by using which you can achieve this

  • $location#url

$location.url($location.path('/company'));

  • $location.search

$location.search('key', null);

See also


Not Related:

When you are using angularjs you can use its built in functions like angular.isDefined

if(angular.isDefined($routeParams.key)){
     $scope.changePassword();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.