My frontend web application is entirely written in HTML5/JavaScript, with the MVC being managed by AngularJS framework using UI-Router.
Now, I am faced with the challenge of managing multiple customers with a single application following this pattern:
- Each customer has an applicationName (System.String)
- The URL to access the application is [domain]/:applicationName/[view state] such as: or
Therefore, in the config function of Angular's bootstrap file, I need to implement something like this:
.state('home.dashboard', {
url: '/:applicationName/home/dashboard',
templateUrl: '/views/contents/dashboard.html'
});
The main issue here is that the applicationName serves as a unique identifier to retrieve the corresponding applicationId (System.Guid) stored in the database. This applicationId is essential for retrieving the data related to the applicationName and is used in all requests.
Hence, my question is: before resolving the state URL, can I fetch the applicationName, make a request to a REST API to obtain the corresponding applicationId, store it in an Angular service, and then proceed to the state?
Is this approach feasible? If so, how can I achieve this?
Thank you very much!
Lorenzo