I would like to add a specific class to my wrapper when my route change so I can control what CSS animation will be triggered.
I try to do it like that : http://plnkr.co/edit/KRwBFb6bCTkit9eKg8yb?p=preview
$rootScope.$on( "$routeChangeSuccess", function(event, next, current) {
//Code to skip animation on the first load/page
if( 'undefined' === typeof current || $scope.pageClass == '' ) return false;
var elem = document.querySelector("#wrapper");
var viewElem = angular.element(elem);
$animate.addClass(viewElem, $scope.pageClass).then(function(){
$animate.removeClass(viewElem, $scope.pageClass);
});
});
But no class is added, am i using this function the wrong way ?