You'll need to develop something similar:
@Injectable()
class UserService() {
private _isLoggedIn = new BehaviorSubject<boolean>(false);
login_user(form: string) {
// Call this._isLoggedIn.next(true) or this._isLoggedIn.next(false) depending on the result
}
get isLoggedIn() {
return this._isLoggedIn.asObservable();
}
}
Then in the component where you want to display the login/logout button, add private userService: UserService in the constructor, then write something like this in the template:
<button>{{ userService.isLoggedIn | async ? 'Logout' : 'Login' }}</button>