Currently, I am delving into the realm of Angular.js and grappling with the concept of ng-model. It appears that ng-model allows us to bind input values to the $scope
object in a controller. However, as I ventured into Angular.js filters, I stumbled upon an example on the official website regarding filters in angular js. The example provided left me puzzled about:
<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>
<label>Equality <input type="checkbox" ng-model="strict"></label><br>
<table id="searchObjResults">
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
<tr ng-repeat="friendObj in friends | filter:search:strict">
<td>{{friendObj.name}}</td>
<td>{{friendObj.phone}}</td>
In analyzing the above snippet of code, my inquiry pertains to how we append parameters to the ng-model and subsequently access them. Especially since ng-init includes "friends," I am curious about the correlation between this initialization and utilizing search for filtering or searching. How does specifying search.name or search.phone facilitate accessing friends.name and friends.phone correspondingly?