tr.row(ng-repeat="i in items | filter:search"
input(type="text" ng-model="search.desc")
input(type="text" ng-model="search.comment")
Run Code Online (Sandbox Code Playgroud)
这非常有效,我可以通过desc和评论过滤项目.
现在,我还需要过滤
两者都将具有大于和小于(在之前/之后)的输入.例如金额:
input(type="text" ng-model="search.amount") //this one would be the minimum value input
input(type="text" ng-model="search.amount") //this one would be the maximum value input
Run Code Online (Sandbox Code Playgroud)
我如何将其与我希望保留的已经工作的desc和注释过滤器结合起来?我想我将不得不编写一些自定义函数 - 但是我可以将这种功能与现有的文本过滤相结合吗?
关于语法的注意事项:在nodejs上使用jade模板引擎
我认为你必须写一些代码来检查数量是否满足.由于过滤器可以链接,我认为它无害.
首先,您指定最小和最大金额
input(type="text" ng-model="search.minAmount") //this one would be the minimum value input
input(type="text" ng-model="search.maxAmount") //this one would be the maximum value input
Run Code Online (Sandbox Code Playgroud)
在您的控制器中,定义一个函数
$scope.matchAmount = function(item){
reuturn item.amount >= $scope.search.minAmount && item.amount <= $scope.search.maxAmount
}
Run Code Online (Sandbox Code Playgroud)
最后,在你的模板中使用它
ng-repeat="i in items | filter:search | filter: matchAmount
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6439 次 |
| 最近记录: |