Reputation: 263
I have the ng-repeat of table like below. What I want to do is to pass the value of t.genre
in filter but it is not working. When the value is get. Its filters the name object of that value and display that into the td
. For example the value is 10
then the name that will be display is jazz.
Note: When I change the t.genre
to 10
the output I get is:
1 simon 10 jazz
8 betty 20 jazz
14 archie 30 jazz
3 jumbo1 40 jazz
what I want is:
1 simon 10 jazz
8 betty 20 rock
14 archie 30 classic
3 jumbo1 40 metal
index.html:
<tr ng-repeat="t in users">
<td>{{t.id}}</td>
<td>{{t.username}}</td>
<td>{{t.genre}}</td>
<td ng-repeat="typ in genre | filter:{ 'id':t.genre}:true">{{typ.name}}</td>
</tr>
and my controller.js:
function Ctrl($scope) {
$scope.users = [
{"id":1,"username":"simon","genre":"10"},
{"id":8,"username":"betty","genre":"20"},
{"id":14,"username":"archie","genre":"30"},
{"id":3,"username":"jumbo1","genre":"40"},
];
$scope.genre = [
{"id":10,"name":"jazz",},
{"id":20,"name":"rock",},
{"id":30,"name":"classic",},
{"id":40,"name":"metal"},
];
}
fiddle link: http://jsfiddle.net/DharkRoses/dk247c3z/1/
any hlp and suggestions thanks in advance.
Upvotes: 0
Views: 65
Reputation: 18734
you can filter it by t.genre
:
http://jsfiddle.net/maio/dk247c3z/2/
Upvotes: 1