import {Component, OnInit, OnDestroy} from '@angular/core'; import {FullnodeService} from '../fullnode.service'; import { UserService } from '../user.service'; import {Subscription, Observable} from 'rxjs'; import {Owner} from '../owner.model'; @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.css'] }) export class HeaderComponent implements OnInit, OnDestroy { public height = 0; private owner: Owner= {_id:'', address: 'none', name:''}; private session: string | null = ''; public heightUpdate: Observable; public ownerUpdate: Observable; constructor( public fullnodeService: FullnodeService, public userService: UserService ){ this.heightUpdate = fullnodeService.heightUpdate; this.ownerUpdate = userService.ownerUpdate; } ngOnInit(){ this.ownerUpdate.subscribe((owner) => { this.owner = owner; }); console.log('Header owner', this.owner); } ngOnDestroy(){ } shortenZaddr() { var addr = this.owner.address; var end = addr.length; var last = end - 5; return addr.substring(0,5).concat('...').concat(addr.substring(last, end)); } }