我的目标是快速创建一个标签,显示与给定出版物相关的所有作者。
$scope.publications.authors
当设置为单个值时,一切正常。当多个值存储在数组中时,它们不起作用,如下所示。
我知道 AngularJS ngShow 指令的条件语句不适用于数组,但我似乎无法弄清楚我实际上应该使用什么。
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"};