Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class AuthService {
- public user$ = new BehaviorSubject<User>(null)
- login (username: string, password: string): void {
- this.httpClient.post<ApiKey>(environment.apiUrl + '/login').subscribe(
- (user) => {
- this.user$.next(user)
- }
- )
- }
- }
- export class AuthLoginComponent {
- constructor (private authService: AuthService) {
- this.authService.login()
- }
- }
- export class NavbarComponent {
- constructor (private authService: AuthService) {
- this.authService.user$.subscribe(
- (user) => {
- console.log(user)
- }
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement