I’m trying to develop a search function that instantly filters out elements in the list that the user is seeing as he types the search terms. I’m new both to ionic and angularjs, but not new to programming or javascript (Most of what I’ve ever worked on was jQuery based).
How do I get an event to be fired on every new character the user types on the search field?
Additionally, where can I find more content about how to use events in ionic? I couldn’t find much information on events when I searched.
function getFilteredItems(filter) {
var collection = $scope.items;
// Filter items
return collection.filter(function(item) {
var itemDoesMatch = !filter || item.name.toLowerCase().indexOf(filter.toLowerCase()) > -1;
return itemDoesMatch;
});
}
I’ve removed most of the code from the examples that I didn’t find relevant so these may not be complete examples. As you can see there are multiple ways to accomplish what you need, it just depends on the complexity of your case.
Any events specific to Ionic can be found at the docs, but since Ionic is built off of Angular you will need to go to their docs to find more information on the Angular events.