Функция Javascript возвращает одно значение, поэтому в этом случае вы можете вернуть объект, массив, строковое значение
Объект
getfullName() {
return {firstName: this.firstname, lastName: this.secondname}
}
Массив
getfullName() {
return [this.firstname,this.secondname];
}
строка
getfullName() {
return `${this.firstname} ${this.secondname}`;
}
Другим способом можно создать функцию, которая будет возвращать разные имена при каждом вызове, на основе массива
Компонент
selectedName ='';
names = ['Tom','Hopkins','Other'];
index =-1;
getNames () {
this.index++;
if (!this.names[this.index]){
this.index = 0
}
return this.names[this.index];
}
setSelectedName(){
this.selectedName = this.getNames();
}
Шаблон
<button (click)="setSelectedName()">Get Name</button> {{selectedName}}
демонстрация stackblitz