如何根据 $location.search() 参数过滤我的结果集?
<div ng-repeat="tag in tags">
<div ng-class="{active:tagged(tag.id)}" ng-click="filter(tag.id)">
{{album.title}}
</div>
</div>
active
如果 tagged 的结果为真,则附加该类。
filter('tagged', function () {
return function (id) {
//Assume "tags" is also the name of the parameter.
//"tags" is being set by $location.search({tags:['123','456','789']});
return ($location.search().tags.indexOf(id) != -1)?true:false;
};
});
里面的约定ng-class
是错误的,但我以此为例来说明知识差距。