0

I have couple of questions regarding $location.path(/helpmeunderstand) . I have a login() method and ones the credentials are successful i want to navigate $location.path(/login/:username), but it does not show the name of the user who is logged in instead it just shows, /login/:username.

Please note i am doing this inside of the $scope.function, but does not work.

$scope.isValidUser = function() {
            gitHubApiFactory.getUserName($scope.gitUserName)
                .success(function (user) {
                    $scope.gitUser = user;
                    $scope.loaded = true;
                    $location.path( "/login/{{user.login}}" );
                    console.log(user);

                })
                .error(function(data, status, headers, config) {
                    $scope.userNotFound = true;
                    $log.log(data.error + ' ' + status);
                });

Any suggestion is welcome.

Thanks

2
  • 1
    Show us some code .... Commented Sep 25, 2014 at 10:21
  • Thanks, code is now in my question Commented Sep 25, 2014 at 10:27

1 Answer 1

3

The problem is that you cannot use the {{}} bracket syntax that way. It only works for HTML templates and bindings.

Try this:

$scope.isValidUser = function() {
            gitHubApiFactory.getUserName($scope.gitUserName)
                .success(function (user) {
                    $scope.gitUser = user;
                    $scope.loaded = true;
                    $location.path( "/login/" + user.login);
                    console.log(user);

                })
                .error(function(data, status, headers, config) {
                    $scope.userNotFound = true;
                    $log.log(data.error + ' ' + status);
                });
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you sir :) saved me lot of time. sorry very new to angularjs

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.