1
Goodnight!
I have a problem with a function in Typescript(Ionic 2). The function does a search/filter from the contents of the tags. The user enters the number you want to search for and the function filters from the number entered. The first time the query screen is called, the function performs normally, no problem, and can even do several searches. However, when leaving the screen and returning to perform more queries, the search no longer works, does not perform the filtering. Can someone 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.
I recommend you a researched on reactive Forms and use the onChanges method to filter your elements. This way that you are doing is not a good way to do it with angular looks more like a jquery/vanilla js solution
– Eduardo Vargas
I believe that the best thing for you would be to read about the Ngmodel of Angular/Ionic its code would look better and in addition it would have some extra properties to help you.
– Lucas Brogni
Cool, I really appreciate the good tips! I will search and modify. Thank you.
– ClaudioJunior10