I'm facing an issue with updating my side menu items based on user data. I have a side menu controller where I need to display the username, and in another controller where I retrieve user data from the database and want to update the menu items accordingly. I've tried using $watch and services but haven't been successful. I'm open to suggestions that don't involve using $rootScope as I'm not familiar with it.
.controller('menuCtrl', function($scope) {
$scope.username = ""
})
.controller('afterloginCtrl', function($scope) {
var a = "this is username"
$scope.username = a // here I wish to update username in menuCtrl
})
If you require more code or further details, please let me know.
EDIT
The challenge lies in updating user information stored in the database table. I need to fetch the latest username and other info from the database and reflect these changes in the menu controller every time the data is updated.