Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49293

Error in typescript function - function executes only once

$
0
0

@Cj10 wrote:

Good evening!

I have a problem with a function in Typescript (Ionic 2). The function performs a search / filter from the contents of the tags. The user enters the number they want to fetch and the function filters from the number entered. The first time the query screen is called, the function executes normally, without problem, and can even perform several searches. However, when you exit the screen and return to it for more queries, the search no longer works, it does not perform the filtering. Can anyone help solve this problem?

myFunction () {

    this.input = document.getElementById ("myInput");
    this.filter = this.input.value.toUpperCase ();
    this.ul = document.getElementById ("myUL");
    this.li = this.ul.getElementsByTagName ("li");

    for (this.i = 0; this.i <this.li.length; this.i ++)
    {
      this.a = this.li [this.i] .getElementsByTagName ("a") [0];

      if (this.a.innerHTML.toUpperCase (). indexOf (this.filter)> -1)
      {
          this.li [this.i] .style.display = "";
      } else {
          this.li [this.i] .style.display = "none";
      }
    }

}
Thanks in advance.

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49293

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>