How can you add and remove a class with multiple class's used?

I have <nav class="navbar navbar-default navbar-custom"> and I need to add 
"navbar-fixed-top" class if window scrolled more than 50px, remove it if 
scrolled less than 50px

I found some code searching but it adds 1 class or removes it, I need to 
add to existing and remove from the set.

http://jsfiddle.net/eTTZj/30/


Code found:
app = angular.module('myApp', []);
app.directive("scroll", function ($window) {
    return function(scope, element, attrs) {
        angular.element($window).bind("scroll", function() {
             if (this.pageYOffset >= 100) {
                 scope.boolChangeClass = true;
                 console.log('Scrolled below header.');
             } else {
                 scope.boolChangeClass = false;
                 console.log('Header is in view.');
             }
            scope.$apply();
        });
    };
});

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to