I am using angular in a project and after the user logs in his data gets saved into the database and he can pass on to the main application. BUT I need to use his name in order to show his orders, so I can extract his name when he logs in but when I want to use this name in another function I get: 'undefined'...?
AngularJS
$scope.redirectafterLogin = function($username)
{
$rootScope.username = $username;
window.location = "index1.html";
}
//SHOW ORDER FOR LOGGED IN CUSTOMER
$scope.orderCustomer = function (){
$http.get('/api/getorderS/'+$rootScope.username).then(function (results)
{
...
}
So how can I access the $rootScope.username variable in my orderCustomer function?