<div ng-repeat="city in cities"> <div>city: {{city}}</div> <div ng-repeat="contact in contacts | filter:selectItems(city)"> contact: {{contact.name}} </div> <hr></div>angular.module("myApp", []) .controller("MyCtrl", function ($scope) { $scope.selectItems = function (item, city) { return item.city === city; }; });上述代碼不起作用。因為在filter filter 篩選函數 selectItems 中有第二個參數city。那么在這種情況下,該怎樣以正式的方式在篩選函數中使用第二個參數呢?或者說,Angular是否允許在篩選函數中添加第二個參數?
(Angular) 怎樣(或能否)在 filter filter 篩選函數中使用第二個參數?
天涯盡頭無女友
2018-12-20 18:15:53