angular.module('directives')
.directive('listItem',[function(){
  return {
    'restrict': 'A',
    'link' :function($scope,$elem,$attrs) {
      $elem.addClass('anchor');
      $elem.on('click',function(){
        angular.element('.anchor').removeClass('active');
        $elem.addClass('active');
      });
    }
  }
}]);
angular.module('directives')
.directive('listItem',[function(){
  return {
    'restrict': 'A',
    'link' :function($scope,$elem,$attrs) {

      $elem.on('click',function(){
        angular.element('.anchor').removeClass('active');
        $elem.addClass('active');
      });
    }
  }
}]);
Remove unnecessary adding of anchor class