I am using Angular 7
I have following template
<div>
{{myService.userInfo.firstName}} {{myService.userInfo.lastName}}
</div>
I want to make it short by substituting user
instead of myService.userInfo
<div>
{{user.firstName}} {{user.lastName}}
</div>
How can I do this like ng-init in AngularJS.
create a getter property that will return the userinfo object
get user(){
return this.myService.userInfo;
}
and use like
<div>
{{user.firstName}} {{user.lastName}}
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With