I have a code as follow:
<input type="text" ng-model="filteredText">
<ul>
<li ng-repeat="item in data | filter: {Name : filteredText}">
</li>
</ul>
When Name property is static it's work correctly. Now I need filter dynamic field. For example:
<ul>
<li ng-repeat="item in data | filter: {propertyName: filteredText}">
</li>
</ul>
In this case propertyName is dynamic and come from $scope
. But this case filter
not working.
After reading the documentation, it looks like you have to do it another way.
<input ng-show="propertyFilter == 'Name'"
type="text"
ng-model="filteredText[propertyName]" />
<ul>
<li ng-repeat="item in data | filter: filteredText">
</li>
</ul>