Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, OnInit } from '@angular/core';
  2. import { Router } from '@angular/router';
  3.  
  4. import { AuthService } from '../core/services/auth.service'
  5. import { CurrentUserService } from '../core/services/current-user.service';
  6.  
  7. import { CurrentUser } from '../core/models/current-user.model';
  8.  
  9.  
  10.  
  11. @Component({
  12.   selector: 'app-home',
  13.   templateUrl: './home.component.html'
  14. })
  15. export class HomeComponent implements OnInit {
  16.  
  17.   currentUser: CurrentUser = new CurrentUser();
  18.  
  19.   constructor(
  20.     private authService: AuthService,
  21.     private router: Router,
  22.     private currentUserService: CurrentUserService) {
  23.   }
  24.  
  25.  
  26.   ngOnInit() {
  27.     let self = this;
  28.     this.currentUserService.loadData().subscribe(
  29.       ( data ) => {
  30.           self.currentUserService.set(data);
  31.           self.currentUser = self.currentUserService.get();
  32.         },
  33.       ( error ) => { alert('error: ' + error) }
  34.     );
  35.   }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement