I have a list of friends which is an array. I have a input field. if i press any letter after @ in that input field, how can i get suggestions of friends from my friends array. Something like Facebook comment box. If i press any letter after @ it immediately shows filtered friends name's with that particular letter.
Question how I can show friends list on any key press after @
<input type="text" id="friendInput" (keypress)="onSearchFriend($event)">
<div class="autocompleteFriendList" *ngIf="filteredFriends.length > 0">
<ul>
<li *ngFor="let friend of filteredFriends">
{{ friend.name }}
</li>
</ul>
</div>
filteredFriends : any = [];
friends : Array<any> = [
{id: 1, name: 'Bob'},
{id: 2, name: 'max'},
{id: 3, name: 'Charlie'},
{id: 4, name: 'jhon'},
{id: 5, name: 'Tom'}
]
onSearchFriend(event : any){
let inputEl : any = document.getElementById(friendInput);
if(event.key == '@'){
}
}