Questions tagged «angular-filters»

15
如何在控制器中使用过滤器?
我写了一个过滤器函数,它将根据您传递的参数返回数据。我希望控制器具有相同的功能。是否可以在控制器中重用过滤器功能? 到目前为止,这是我尝试过的: function myCtrl($scope,filter1) { // i simply used the filter function name, it is not working. }

8
如何在AngularJs中使用ng-repeat过滤(键,值)?
我正在尝试做类似的事情: <div ng-controller="TestCtrl"> <div ng-repeat="(k,v) in items | filter:hasSecurityId"> {{k}} {{v.pos}} </div> </div> AngularJs部分: function TestCtrl($scope) { $scope.items = { 'A2F0C7':{'secId':'12345', 'pos':'a20'}, 'C8B3D1':{'pos':'b10'} }; $scope.hasSecurityId = function(k,v) { return v.hasOwnProperty('secId'); } } 但是不知何故,它向我展示了所有物品。如何筛选(键,值)?


4
AngularJS:自定义过滤器和ng-repeat
我是AngularJS的新手,我正在构建一个小型的概念验证租车清单应用程序,该应用程序会提取一些JSON,并通过ng-repeat并使用几个过滤器来呈现这些数据的各个部分: <article data-ng-repeat="result in results | filter:search" class="result"> <header><h3>{{result.carType.name}}, {{result.carDetails.doors}} door, £{{result.price.value}} - {{ result.company.name }}</h3></header> <ul class="result-features"> <li>{{result.carDetails.hireDuration}} day hire</li> <li data-ng-show="result.carDetails.airCon">Air conditioning</li> <li data-ng-show="result.carDetails.unlimitedMileage">Unlimited Mileage</li> <li data-ng-show="result.carDetails.theftProtection">Theft Protection</li> </ul> </article> <h2>Filters</h2> <h4>Doors:</h4> <select data-ng-model="search.carDetails"> <option value="">All</option> <option value="2">2</option> <option value="4">4</option> <option value="9">9</option> </select> <h4>Provider:</h4> Atlas Choice <input type="checkbox" …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.