我想在使用auth0登录时显示用户的名字。当用户登录时,名称未显示在导航栏中。但是当我们重新加载页面时,名称会出现。
app.component.ts文件
import { Component, AfterViewInit } from '@angular/core';
import {SignupService} from './services/signup.service';
import {Auth} from './services/auth.service';
declare var $: any;
@Component({
moduleId:module.id,
selector: 'my-app',
templateUrl: 'app.component.html',
styleUrls: ['./assets/css/navbar.css'],
providers: [SignupService],
})
export class AppComponent {
profile : any;
constructor(private auth: Auth){
this.profile=JSON.parse(localStorage.getItem('profile'));
};
ngAfterViewInit() {
$(".button-collapse").sideNav();
$(".dropdown-button").dropdown();
}
}