Here is the code snippet that I am working with:
<input ng-model="search" type="text">
<td ng-repeat="key in targets">
{{ display_names[key] }}
</td>
To clarify further:
targets
contains IDs likekey012
display_names
is an object with keys such askey012: "USA"
I want to filter the values in display_names
based on the search input. While I know how to filter key
using AngularJS documentation, I am still figuring out how to filter display_names
.
Example
Here's a complete example:
var TS = angular.module('myapp', []);
TS.controller('test', function($scope) {
$scope.targets = ["id_1", "id_2"];
$scope.display_names = {
"id_1": "USA",
"id_2": "Mexico"
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myapp" ng-controller="test">
<input ng-model="search" placeholder="Search...">
<ul>
<li ng-repeat="key in targets">{{display_names[key]}}</li>
</ul>
</body>