Open abwaters opened 4 years ago
My code. My server puts user name in user?.Identity, but you can model the DTO any way you want.
// header.component.ts snippet // inserted into ngOnInit this.auth.getUser() .subscribe((data: any) => { console.log(data); this.user = data; });
// header.component.html snippet <nb-user [nbContextMenu]="userMenu" [onlyPicture]="userPictureOnly" [name]="user?.Identity" [picture]="'data:image/jpeg;base64,'+user?.Avatar">
same here.
<nb-user [nbContextMenu]="userMenu"
[onlyPicture]="userPictureOnly"
[name]="username"
[picture]="user?.picture">
</nb-user>
username: string;
....
ngOnInit() {
....
this.storageService.changes
.subscribe((changes: any) => {
....
this.username = user.id.userid;
console.log(this.username);
....
});
The log shows the username properly. However it does not show into the component.
If I set it explicitly the value:
username: string = 'myname';
this works
Any update on this issue?
Issue type
I'm submitting a ... (check one with "x")
Issue description
Current behavior:
I have a service that allows a user to login and logout and I'm updating the [name] input on the nb-user component in the header (header.component.ts). I logout and log back in as another user and update the user information in the header when this happens.
The change is not detected and i'm not sure how to do this correctly or if this is a defect.
Expected behavior:
I would update the value that is bound to the nb-user component name attribute and the component would update accordingly.
Steps to reproduce:
Bind a value to the name attribute and change it later.
Related code:
// header.component.ts snippet // inserted into ngOnInit this.authService.getUser().subscribe(user => { this.userName = user.attributes.name; console.log(
User logged in: ${this.userName}
); });// header.component.html snippet <nb-action class="user-action" *nbIsGranted="['view', 'user']" > <nb-user [nbContextMenu]="userMenu" nbContextMenuTag="user-menu" [onlyPicture]="userPictureOnly" [name]="userName">
Other information:
npm, node, OS, Browser
Angular, Nebular