Search bar

41884506_2222362354458424_2295215881438887936_n

Hi!
I’m trying to create a search bar that filters a list taken from an external server, the problem is:
when i digit a letter in the search bar it filters correctly but when I eliminate the letters the list remained filtered instead of giving me back the list.
I hope you can help me, thank you for the attention!

I think if you change your search-bar.ts file like this it could work. since you remove the last letter of your search bar, you won’t filter back to the initial state.

this.nations = this.nations.filter((nation) => {
    return (val && val.trim() != '') ?
        nation.name.toLowerCase().indexOf(val.toLowerCase()) !== -1 :
        true
});