我有一個包含多個過濾器文件(每列一個)的表。AngularJS 1.x:空列上的過濾器錯誤(?)
<table>
<tr>
<th><input type="text" ng-model="search.name"></th>
<th><input type="text" ng-model="search.phone"></th>
<th><input type="text" ng-model="search.secret"></th>
<th><input type="text" ng-model="search.nullcol"></th>
</tr>
<tr ng-repeat="user in users | filter:search:strict">
<td>{{user.name}}</td>
<td>{{user.phone}}</td>
<td>{{user.secret}}</td>
<td>{{user.nullcol}}</td>
</tr>
</table>
一切正常,除了在包含空值的列過濾罰款:當我輸入的過濾領域的東西,用空的所有行消失了(正確),但刪除過濾器就不會恢復它們。
這裏有一個plunkr:https://plnkr.co/edit/viMHsxBHI4CjfjWqWjti
有沒有一種方法,使工作?
我可能已經找到了一個解決方案:我把一塊手錶放在過濾器字段上,當空的時候,我從搜索對象中刪除屬性。 這是更新的plunkr:https://plnkr.co/edit/7wE58QBUAqPHe8CGb4Bj 不過,我想知道是否存在更優雅的解決方案。 – archimede