Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ng-Model="something.$" what does this mean?

I'm new to Angular and I was reading over the filter documentation and I saw this code.

    <label>Any: <input ng-model="search.$"></label> <br>
    <label>Name only <input ng-model="search.name"></label><br>
    <label>Phone only <input ng-model="search.phone"></label><br>


    <tr ng-repeat="friendObj in friends | filter:search:strict">

I'm unclear on what the ng-model="search.$" means. The two way binding with ng-model is clear, but what about the "search.$"? What is that doing and how does it work with the filter.

I tried searching for this and couldn't find anything. Thanks!

like image 404
Luke Schunk Avatar asked Oct 26 '15 16:10

Luke Schunk


1 Answers

It is specific to the filter logic. $ is used as a property matcher to match against the values of all the properties on the object in the list. So here in your filter the bound expression is the object search and specifying the matcher string as $ property (which is the ng-model for the search input) on search will enable the filter to compare values on all the properties of friendObj for a match.

See doc

Note that a named property will match properties on the same level only, while the special $ property will match properties on the same level or deeper. E.g. an array item like {name: {first: 'John', last: 'Doe'}} will not be matched by {name: 'John'}, but will be matched by {$: 'John'}.

like image 145
PSL Avatar answered Sep 23 '22 02:09

PSL