How to search using @ and # tags in input?

Hello, I am making a post similar to a Facebook post, when I post data in the post when I type “@” to search data that return users names and if I type “#” first to call API and return available tags in ionic 4.

Here what I have done:


        <ion-textarea rows="3" (ionInput)="searchPeople($event)" cols="20" formControlName="comment"
          placeholder="Tweet your reply" spellcheck="true" autoComplete="true" autocorrect="true" autofocus required>


searchPeople(ev: any) {
    // set val to the value of the searchbar
    let val =;
    let firstchar = val.charAt(0);

    if (firstchar = "@") {
      console.log("search people");
    else if (firstchar = "#") {
      console.log("hash tag");
    } else {

I did like this but it’s not working…