javascript - How to use ng-toggle and ng-class to change icon while using ng-click:predicate -
i'm using predicate
sort items in data model. i've working on adding in , down arrow icons show state sort in.
example of predicate orderby in action: http://plnkr.co/edit/?p=preview
not sure how toggle values within predicate:
<button type="button" class="btn btn-default" ng-click="predicate = 'added_epoch'; reverse=!reverse;"> <div ng-class="recentadded == 'up' ? 'iconupbig' : 'icondownbig'"></div> added </button>
controller
$scope.recentadded = 'up'
i'm not using function here, why it's bit hard me see how toggle now.
is there way hook , change recentadded
var?
inturn change ng-class
:
ng-click="predicate = 'added_epoch'; reverse=!reverse;"
then based on predicate, toggle ng-class
:
ng-class="recentadded == 'up' ? 'iconupbig' : 'icondownbig'"
i add scope function. don't want put logic in markup it's hard see what's going on.
// accept predicate using parameter $scope.togglesort = function() { // whatever other logic need if ($scope.recentadded === 'up') $scope.recentadded = 'down'; else $scope.recentadded = 'up'; };
Comments
Post a Comment