Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Service
- currentUser: BehaviorSubject<ApplicationUser>;
- constructor(private http: HttpClient, private router: Router) {
- this.currentUser = new BehaviorSubject(JSON.parse(localStorage.getItem('currentUser')));
- }
- ## Component
- currentUser: ApplicationUser;
- ngOnInit() {
- this.authService.currentUser.subscribe((userData: ApplicationUser) => { this.currentUser = userData; });
- }
- ## Setter of currentUser
- func() {
- const user: ApplicationUser = {
- Email: 'as',
- Id: 'a12'
- };
- this.authService.currentUser.next(user);
- }
Advertisement
Add Comment
Please, Sign In to add comment