Reputation: 959
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
Upvotes: 0
Views: 104
Reputation: 13796
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);
});
Upvotes: 3