I am new to AngularJS and I am looking for help on retrieving information about the logged-in user. I want to be able to display this information but I'm not sure where to start. Here is my main Angular controller:
var myApp = angular.module('myApp', ['ngResource', 'ngRoute']);
myApp.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/main.html',
access: {restricted: true}
})
// Other route definitions...
});
// Run function to handle route changes and user authentication check
myApp.run(function ($rootScope, $location, $route, AuthService) {
$rootScope.$on('$routeChangeStart', function (event, next, current) {
AuthService.getUserStatus().then(function(){
if (next.access.restricted && !AuthService.isLoggedIn()){
$location.path('/login');
$route.reload();
}
});
});
});
// Controller for handling meetups
myApp.controller('meetupsController', ['$scope', '$resource', 'AuthService', function ($scope, $resource, AuthService) {
// Meetup resource initialization and query
}]);
// Controller for handling user data
myApp.controller('userController', ['$scope', '$resource', function ($scope, $resource) {
// User resource initialization and query
}]);
If anyone can provide some code examples or guidance, it would be greatly appreciated.