I have created the login, register, change password and logout services (and they work). The username displays instead of the log in button after the user is logged in, but the user needs to refresh the site or navigate to a different url for the username to be displayed.
location.reload() solves the issue, but it's not exactly the best thing to do here.
My authentication routes are structured like this:
In app-routing.module.ts I have:
path: 'auth',
loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule)
Then in pages-routing.module I have the authentication routes, for example:
path: 'login',
component: LoginComponent
I use a service for each authentication process located in app/services/ and the components are in the app/pages/ directory.
EDIT: To clarify: The login form is a popup that can appear in every page of my website. So the button that opens the log in form is replaced with the username once a user logs in, but this happens when the user reloads the page or navigates to a different url. I want this to happen as soon as a user logs in (or registers, logs out etc) and I want the user to stay on the same page. One way I can think of doing it is to quickly navigate to another page and then come back to the same page but I don't think that's a good solution