I'm trying to implement a filter based on the answer to this question, but it isn't working for me. For code:
function MyCtrl($scope, $timeout)
{
$scope.tweets = [
{
created_at: "Date",
text: "tweet text",
users:
[
{
name: "user name",
screen_name: "user screen name",
profile_image_url: "profile pic"
},
{
name: "user name 2",
screen_name: "user screen name 2",
profile_image_url: "profile pic"
}
]
},
{
created_at: "Date",
text: "tweet text 2",
users:
[
{
name: "user name",
screen_name: "user screen name",
profile_image_url: "profile pic"
},
{
name: "user name 2",
screen_name: "user screen name 2",
profile_image_url: "profile pic"
}
]
},
{
created_at: "Date",
text: "tweet text 3",
users:
[
{
name: "user name",
screen_name: "user screen name",
profile_image_url: "profile pic"
},
{
name: "user name 2",
screen_name: "user screen name 2",
profile_image_url: "profile pic"
}
]
}
];
}
and the template:
<div ng-app ng-controller="MyCtrl">
<div ng-repeat="tweet in tweets">
for each tweet, user 2's name should be printed here >>
{{(tweet.users | filter:{screen_name:'user screen name 2'}).name}}
_____________________________________
</div>
</div>
I'm seeing output of:
for each tweet, user 2's name should be printed here >>
for each tweet, user 2's name should be printed here >>
for each tweet, user 2's name should be printed here >>
I would expect that "user name 2" would be printed out after each ">>". I don't know why that filter isn't working on an array of each iterated element. Thanks.