Guest User

Untitled

a guest
Aug 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## AuthService
  2. private currentUser: Subject<ApplicationUser>;
  3. user$: Observable<ApplicationUser>;
  4.  
  5.   constructor(private http: HttpClient, private router: Router) {
  6.     this.currentUser = new Subject();
  7.     this.user$ = this.currentUser.asObservable();
  8.   }
  9.   getCurrentUserInfo() {
  10.     this.currentUser.next(new ApplicationUser('asd', 'asd'));
  11.   }
  12.  
  13. ## Component
  14.  
  15. currentUser: ApplicationUser;
  16.   ngOnInit() {
  17.     this.authService.checkAccess();
  18.     this.authService.user$.subscribe((userData) => { this.currentUser = userData; });
  19.   }
  20.  
  21. ## Widok
  22.  
  23. <a>{{(currentUser)?.Email}}</a>
Advertisement
Add Comment
Please, Sign In to add comment