Ankit Rai

Ankit Rai

  • 861
  • 628
  • 9.1k

Angular 17 Subject behavior issue

Apr 21 2024 10:50 AM

Yassin Mo  I am create a project with angular 17..
 after create application app.module.ts file is not available.
I have a seprate module for login.
i have a seprate component for navbar. In the login component i create a property name login. Click on Login Button i have store all data with authenticationService. After storing login data in authentication service i have create a observable like this  loggedIn= new BehaviorSubject<boolean>(false);


  get isLoggedIn() {
    return this.loggedIn.asObservable();//push Interface
  }
in login method send  

this.loggedIn.next(true);
and this observale in the app.component.ts  

this.isLoggedIn$ = this.authenticationService.loggedIn;
but when i am login this.isLoggedIn$ is not working if i am refresh the page its working fine. 


Answers (3)