How to use the AngularJS ngShow directive to show only if an element is in
an array?
My goal is to, rapidly, have a tag displaying all the authors associated
with a given publication.
Everything works when $scope.publications.authors is set to a single
value. They do not work when multiple values are stored in an array, as
shown below.
I know that the conditional statement for the AngularJS ngShow directive
isn't the proper one to use for arrays, but I can't seem to figure out
what I actually should use.
HTML:
<div ng-repeat="person in persons" ng-show="person.firstName ==
publication.authors">{{person.firstName}}</div>
JS:
$scope.publications = [
{"title": "Research Paper",
"authors": ["Bill", "George"]};
$scope.persons = [
{"firstName": "Bill",
"lastName": "Smith"},
{"firstName": "George",
"lastName": "Jones"},
{"firstName": "Mike",
"lastName": "Thomas"};
No comments:
Post a Comment