Currently, I have implemented the following code to handle resource resolution when the main state is loaded. However, I am looking for a way to re-resolve the resource without having to reload the page. Reloading the page would negatively impact the user experience, so I am seeking an alternative solution.
$stateProvider
.state('main', {
url: '/',
templateUrl: 'publicApp/main.html',
controller: 'MainCtrl as mainCtrl',
resolve: {
userData: ["UserApi", function (UserApi) {
return UserApi.getUserData().$promise;
}]
}
})
.controller('MainCtrl', function (userData) {
console.log(userData.something);
})
On this public site, users can access pages without logging in, but upon logging in, the page should display customized content based on their data.
EDIT
As login is facilitated through a modal that doesn't trigger a page reload afterward, my initial idea of using $rootScope
events and listeners across controllers seems inelegant. Therefore, I am exploring better alternatives.
At present, I am considering two options:
- Reloading the page - although it's not ideal due to the impact on user experience
- Using events to communicate between the login modal and other controllers
Do you have any innovative suggestions?