我无法在angularjs中过滤罗马数字。我有四个用于搜索的输入区域,图像如下:
选择班级'I'后: -
结果:
Name Class
-----------
xyz I
abc II
ebc VI
接受: -
Name Class
-------------
xyz I
代码:
模型是 ng-model =“searchClass”
<tr ng-repeat="defaulterList in defaulterLists| filter:searchText | filter:searchClass | filter:searchSection | filter:horsepowerFilter">
即使我尝试使用过滤器中的属性,例如 filter:searchClass.class 但不能正常工作
过滤代码:
<tr ng-repeat="defaulterList in defaulterLists| filter:searchText | filter:searchClass | filter:searchSection | filter:horsepowerFilter">
<td>{{$index + 1}}</td>
<td>{{defaulterList.admno}}</td>
<td>{{defaulterList.name}}</td>
<td>{{defaulterList.mobile_no}}</td>
<td>{{defaulterList.class}}</td>
<td>{{defaulterList.section}}</td>
<td>{{defaulterList.total}}</td>
<td><select ng-model="defaulterList.msgid" class="full-width"> <option value="">-select-</option><option ng-repeat="message in messages" value="{{message.id}}">{{message.title}}</option></select></td>
<td><button class="btn-success btn-small" ng-click="sendSms(defaulterList)">Send SMS</button></td>
</tr>
答案 0 :(得分:1)
试试这个
$scope.data = {};
$scope.data.defaulterLists = $scope.defaulterLists;
并将searchText
更改为$scope.data.searchText
。它现在应该工作。
使用ng-repeat作为
<tr ng-repeat="defaulterList in data.defaulterLists| filter:data.searchText | filter:data.searchClass | filter:data.searchSection | filter:data.horsepowerFilter">
答案 1 :(得分:0)
我遇到了同样的问题。
只需更改
来自
过滤器:searchClass 强>
到
过滤器:searchClass:真强>
答案 2 :(得分:0)
$scope.romanize = function(num){
if (!+num)
return false;
var digits = String(+num).split(""),
key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
"","I","II","III","IV","V","VI","VII","VIII","IX"],
roman = "",
i = 3;
while (i--)
roman = (key[+digits.pop() + (i * 10)] || "") + roman;
return Array(+digits.join("") + 1).join("M") + roman;
}