$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
は、タグ付けの結果が true の場合に追加されます。
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
は間違っていますが、知識のギャップを示す例として使用しています。