Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import { Component, OnInit, ViewEncapsulation } from '@angular/core';
  2. import { Observable } from 'rxjs/Rx'
  3.  
  4. import { ProfileService } from '../../../global/services/profile/profile.service';
  5. import { Usuario } from '../../../global/interfaces/usuario.model';
  6.  
  7. @Component({
  8. selector: 'app-topbar',
  9. templateUrl: './topbar.component.html',
  10. styleUrls: ['./topbar.component.css'],
  11. encapsulation: ViewEncapsulation.Emulated
  12.  
  13. })
  14. export class TopbarComponent implements OnInit {
  15. idLogado;
  16. fotoLogado;
  17. data: any;
  18.  
  19. constructor(private profileService: ProfileService) {
  20. this.idLogado = localStorage.getItem('id');
  21. this.fotoLogado = ('assets/imgs/blank-user.jpg');
  22. this.profileService.InitialiseProfile(this.idLogado);
  23. }
  24.  
  25. ngOnInit() {
  26. console.log('=> SettibngsComponent');
  27. this.data = this.profileService.usuarioStream
  28. .subscribe(data => {
  29. this.data = data;
  30. this.fotoLogado = (data.perfil.foto || 'assets/img/blank-user.jpg');
  31. });
  32. }
  33.  
  34. ngAfterViewInit() {
  35. console.log('=> TopbarComponent AfterInit');
  36. // console.log(JSON.stringify(this.data), null, 4);
  37. // console.log(this.data);
  38. Observable.interval(3000).flatMap(() => {
  39. return this.profileService.usuarioStream;
  40. }).subscribe((data) => {
  41. data = this.data = data;
  42. this.fotoLogado = (data.perfil.foto || 'assets/img/blank-user.jpg');
  43. });
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement