我设法显示了当前用户的电子邮件,但是如何获取用户 ID?
Template:
<div *ngIf="!hasLoggedIn">
{{ (profile$ | async)?.email }}
</div>
TypeScript:
import { Profile, GetProfile, ProfileState, } from '@abp/ng.core';
export class Component implements OnInit {
@Select(ProfileState.getProfile) //State
profile$: Observable<Profile.Response>; //Model
get hasLoggedIn(): boolean {
return this.oAuthService.hasValidAccessToken();
}
constructor(private oAuthService: OAuthService) {}
ngOnInit() {
this.store.dispatch(new GetProfile()).subscribe(); //Action
}
}
里面app-routing.module.ts
有 import of ApplicationLayoutComponent
,里面有一个变量声明,currentUser $: Observable <ApplicationConfiguration.CurrentUser>;
用于在导航栏中显示用户名,在ApplicationConfiguration
模型内部有一个 Id,但我无法像使用电子邮件那样实现它
Ps:对不起我的英语