Studying AngularJS tutorial https://docs.angularjs.org/tutorial/step_05 . Also there is a live demo: http://angular.imtqy.com/angular-phonecat/step-5/app/
Search: <input ng-model="$ctrl.query" /> <li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query"> <span>{{phone.name}}</span> <p>{{phone.snippet}}</p> </li> So: how does this very filter work: $ ctrl.query ? Obviously, the script cycles through the entire array of phones objects, and if there is a match with the entered text, the current value is returned to the output after filtering. But the filter is designed so that it looks at all the fields, even those that are not visually displayed. For example, if our phones array is:
[ { "name": "Motorola XOOM with Wi-Fi", "snippet": " ... ", "sys": "hidden value" }, { "name": "MOTOROLA XOOM", "snippet": "... ", "sys": "hidden value" } ] and in <input ng-model="$ctrl.query" /> enter the hidden value , the filter will also work. Although I would like to filter only by the name field. Or implement a filter with a regular expression. Suppose you can replace any letter with an asterisk. In general, how to implement the filter function?