I'm not sure why the filter I'm using doesn't work, if it is too late to filter the categories once they have loaded or if I am just approaching this totally wrong.
Since updateAvailableMusic() runs onload, and filterAvailableCateories() gets run onclick from the html file as such :
"ng-click='filterAvailableCategories(party)'"
I am wondering if I need to be passing more information to the filter function. And as this is Angular and I don't really understand how to debug Angular (read: "follow it through with a breakpoint the way I would normal javascript", I am hoping to get another perspective on this and much thanks ahead of time.
Here is the code:
$scope.updateAvailableMusic = function () {
return music.getMusicCategories(null, $scope.featureType).then(function (options) {
$scope.availableCategoriesUnmapped = options;
$scope.addDefaultCategories();
$scope.availableCategories = _.groupBy(options, 'category');
});
};
$scope.filterAvailableCategories = function (musictype) {
$scope.availableCategories = $scope.availableCategories.filter(function (rr) {
switch (musictype) {
case 'party':
if (rr.category !== 'Rap' && rr.category !== 'HipHop') {
return rr;
}
break;
case 'study':
if (rr.category !== 'Classical' && rr.category !== 'Jazz') {
return rr;
}
break;
}
});
};
Aucun commentaire:
Enregistrer un commentaire