Reputation: 585
i have this Code in my view
<div ng-repeat="config in configs">
<div ng-repeat="test in tests ">
<a href="#"> {{test[config.Name]}}</a></li>
</div>
</div>
it works fine. But how can I filter test?
<div ng-repeat="test in Tests | filter:{[config.Name]:'Test'} ">
dont work. How can I filter the column config.Name?
Thanks for your Help
Stefan
Upvotes: 2
Views: 30
Reputation: 54741
That's a tricky one, but if you put the filter value in a variable first that might work?
<div ng-repeat="config in configs" ng-init="$filter = {}; $filter[config.Name] = 'Test'}">
<div ng-repeat="test in tests | filter : $filter">
<a href="#"> {{test[config.Name]}}</a></li>
</div>
</div>
Upvotes: 0
Reputation: 691635
Add that function to your controller:
$scope.createFilter = function(property, value) {
var result = {};
result[property] = value;
return result;
};
and use it in the view:
<div ng-repeat="test in Tests | filter: createFilter(config.Name, 'Test')">
Upvotes: 2
Reputation: 1152
Try this, I hope that could help you:
JS :
$scope.conf = [];
$scope.conf.Name = 'Test';
HTML:
<div ng-repeat="config in configs | filter:conf:strict">
<div ng-repeat="test in tests ">
<a href="#"> {{test[config.Name]}}</a></li>
</div>
</div>
Upvotes: 0