Quando carrego a page, o valor setado na variavel '"Cliente" só é carregado depois que atualizo a pagina com F5.
base.component.html
base.component.ts
import { Component, OnInit } from '@angular/core'; import { LocalStorageUtils } from '../../Utils/localstorage'; import { ClienteOperadorModel } from '../../../modules/gerencial/seleciona-cliente/models/cliente-operador.model';
@Component({ selector: 'app-base', templateUrl: './base.component.html', styleUrls: ['./base.component.scss'] }) export class BaseComponent implements OnInit { public Cliente; public appName; public menuExpanded = window.innerWidth > 600; constructor(private localstorage: LocalStorageUtils) { }
toggleMenu() { this.menuExpanded = !this.menuExpanded; }
hideMenu() { if(window.innerWidth <= 600){ this.menuExpanded = false; } }
ngOnInit(): void { this.Cliente = this.localstorage.obterDadoStorage('antecipa.user.clienteLogado').nomeOperador; } }