Reputation: 397
I have an observable like below,
this.user$ = of(this.userService.getUserState());
I am binding usrFullNm of it in html,
<p id="on-board" class="on-board-text" *ngIf="(user$|async) as
user">
{{
'OVERVIEW.WELCOME_SCREEN_ON_BOARD'
| translate
: {
USER_NAME:
user.usrFullNm
}
}}</p>
mY user.usrFullNm is like
Mike, Hasan i.e == > [FN,LN]
Now I want to display only LN,for that I am not able to modify the observable,like
this.user$.usrFullNm.split(',')[1]
Or do I need to change in the userService?
can any one suggest me help.Thanks.
Upvotes: 0
Views: 43
Reputation: 893
You need to do as below
this.user$ = of(this.userService.getUserState())
.pipe(map(user=>user.usrFullNm.split(',')[1]))
The map we are using is a Rxjs operator. you can learn all operators here (https://www.learnrxjs.io/operators/).
Upvotes: 1