I am currently working with two separate apps on a single page.
Navbar Module
This module is situated in the navbar of the page and is included on every page of the application through the master layout file (using Laravel). It contains functions like search, logout, and login.
Posts Module
This module is only displayed on the Dashboard page of the application. It loads and displays posts from the backend.
Both of these apps are currently loaded separately using angular.bootstrap
. However, they both require the use of a common service called UserService
. This service retrieves details of the logged-in user and is part of a different module called myapp.utils
. The issue is that when I inject the service into both apps, the User object is created twice, which is not desired. The code snippet provided shows the log being printed twice in the console.
.factory('UserService', function(){
console.log("Initializing UserService");
return {
'User':...
}
})
Combining both apps into a single larger module is not an option since they are declared in two different blade templates (server view files).
I am seeking alternative strategies to resolve this issue. Any suggestions would be appreciated.