如何过滤下面的JSON对象,以便只显示日期为“01 -2015”的名称?当我尝试使用下面的过滤方法时,我最终得到HTML内容中的“[] []”。如果有解决方案,我如何显示每个数组的名称而不是HTML返回['Susan Hill','Petrona Morgan']?
var annApp = angular.module('anniversaries', []);
<div ng-app="anniversaries" class="row" ng-controller="annList">
<div class="mdl-card__supporting-text text2" >
<p ng-repeat="ann in anns">{{ ann.names | filter:{$:"01-2015"} }}</p>
</div>
<script>
annApp.controller('annList', function ($scope) {
$scope.anns = [
{'date':'01-2015','year': '45',
'names': ['Susan Hill', 'Petrona Morgan ']},
{'date': '01-2015', 'year': '35',
'names': ['Terisa Branson', 'Jo Fox', 'Genette McKown']}
];
});
</script>
答案 0 :(得分:2)
尝试
<p ng-repeat="ann in anns | filter: {date : '01-2015'}">
<span ng-repeat="name in ann.names">{{name}}<br/></span>
</p>