My angularjs webapp contains Login view and Home view.
After logging in, I want my credentials to be saved in order to use them in the future.
For this I saved them in my $rootScope.
Now in my homeController I set them to my $scope this way:
$scope.user = $rootScope.user;
$scope.password = $rootScope.password;
and in my HomeController, the value is properly passed.
When I try to set the value of $scope.user to my DOM using {{using}}, it doesnt seem to work.
Here is the HomeController
'use strict';
angular.module('Home')
.controller('HomeController', ['$scope', '$rootScope',
function ($scope, $rootScope) {
$scope.user = $rootScope.username;
}]);
and here is my home view:
<div ng-controller="HomeController as HomeCtrl">
<h1></h1>
<p>{{user}}</p>
<p><a href="#/login">Logout</a></p>
</div>
What am I doing wrong? Sorry for the nooby question and feel free to add more info on how to manage such scenario.