Use function return value as string in Angular 2

This is the markup in which I want to put the return value:

<h2>{{getSelectedUserName}}</h2> 

This is the function I want to use that returns a string:

 public getSelectedUserName(): string { let firstName = this.selectedUser.name.split("\\s+")[0]; console.log(this.selectedUser.name.split("\\s+")); console.log(firstName); return firstName; } 
+5
source share
1 answer

You are not calling a function. You need

 {{ getSelectedUserName() }} 
+7
source

All Articles