我正在按照教程 Codepen 示例在这里对表格进行 Angularjs 搜索:
https://codepen.io/sevilayha/pen/AmFLE
假设我从服务器收到的美味数字是 255, 65551, 32322 ,其中最后两位数字应该是小数。
因此,为了以全面的方式向用户显示它们,我在 html 上做了:
{{ roll.tastiness/100 | number : 2}}
在表中:
<tr ng-repeat="roll in sushi | orderBy:sortType:sortReverse | filter:searchFish">
<td>{{ roll.name }}</td>
<td>{{ roll.fish }}</td>
<td>{{ roll.tastiness/100 | number : 2}}</td>
请注意,我没有修改 codepen 中的代码,因为它不是我的,但您可以在那里尝试修改。
我将控制器中的数据值(再次,不保存代码笔)更改为:
$scope.sushi = [
{ name: 'Cali Roll', fish: 'Crab', tastiness: 255 },
{ name: 'Philly', fish: 'Tuna', tastiness: 466 },
{ name: 'Tiger', fish: 'Eel', tastiness: 7 },
{ name: 'Rainbow', fish: 'Variety', tastiness: 6 }
];
问题是,即使数字显示为 2.55 和 4.66,在搜索中我必须输入 255 而不是 2.55 才能找到记录。
为了使搜索检测到值作为它们在页面上的显示方式而不是 $scope.sushi 对象数组中显示的值,我应该怎么做?