join属性:
例如:
数组name=['John', 'Sebastian', 'Will', 'James'];
若是想把数组中的对象全部筛选并显示出来,可以直接在HTML里面运用angular-filter中的join属性;
用法<p>{{ names | join:', ' }}</p>
name为数组名称,join:','显示数组的连接符
unique属性:
unique属性为筛选出数组中唯一的对象
var name = $filter('unique')(筛选的数组,'筛选条件');
例如:
$scope.orders = [
{ id:1, customer: { name: 'John', id: 10 } },
{ id:2, customer: { name: 'William', id: 20 } },
{ id:3, customer: { name: 'John', id: 10 } },
{ id:4, customer: { name: 'William', id: 20 } },
{ id:5, customer: { name: 'Clive', id: 30 } }
];
var name = $filter('unique')(orders , 'name');
筛选结果为:
$scope.name =[
{ id:1, customer: { name: 'John', id: 10 } },
{ id:2, customer: { name: 'William', id: 20 } },
{ id:5, customer: { name: 'Clive', id: 30 } }
]
筛选出orders数组中name唯一的对象;