1

I want to redirect the users, to their user profile page, after they successfully login (or their login is successfully authenticated). I take the users to their profile pages through the dynamic hyper link below:

  #/{{getAccountTypeName($parent.user.account_type)}}/{{$parent.user.handle}}

And I've located where my users are authenticated at login. But How can I take a dynamically populated URL such as above, in angular JS and call it as a redirect in the below authentication statement. (I am new to angular)

            var email = $scope.loginForm.email;
            var password = $scope.loginForm.password;
            auth.login(
                email,
                password,
                function (data) {
                    if (data.success == true) {
                        $scope.initLogin();
                        $scope.loginCallback(data);
                        $scope.showWelcome = true;
                        addPointsLogin();
                        $("#welcomeModal").modal();
                        $scope.cancel = function () {
                            $("#welcomeModal").modal("hide");
                        };

                    }
                    else {
                        alert(data.error_message);
                    }
                }
0

1 Answer 1

1
app.controller('myCntrl', ['$http', '$scope', '$route', '$routeParams', '$location',
      function($http, $scope, $route, $routeParams, $location){
  var email = $scope.loginForm.email;
  var password = $scope.loginForm.password;
            auth.login(
                email,
                password,
                function (data) {
                    if (data.success == true) {
                        $scope.initLogin();
                        $scope.loginCallback(data);
                        $scope.showWelcome = true;
                        addPointsLogin();

                        $location.path(path); // Put your path here
                        console.log($routeParams); // Here you get your URL data

                        $("#welcomeModal").modal();
                        $scope.cancel = function () {
                            $("#welcomeModal").modal("hide");
                        };

                    }
                    else {
                        alert(data.error_message);
                    }
                }
}]);
Sign up to request clarification or add additional context in comments.

4 Comments

Yes, but how could I include my dynamic URL in this solution?
#/{{getAccountTypeName($parent.user.account_type)}}/{{$parent.user.handle}}
var username = getAccountTypeName($parent.user.account_type); var parent =$parent.user.handle; $location.path('#/'+username+'/'+parent);
Could you show me how that would work within the solution above? Once I include the variables, how could I call them above?

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.