DOM manipulations in angularjs should not be in controller, services etc... But it it should be in the only one place directives...
if you want to manipulate a DOM you should use directive and make your manipulation in there...
here is some good articles about DOM manipulations in angularjs...
Best Practice - Dom Manipulations
DOM Manipulation in AngularJS — Without jQuery
now let's try create a directive like you want. It looks like you want to manipulate element by selecting them via their class. Ok no problem so we need to create a directive which has restrict:'C'
means CLASS...
here is our directive declaration... (verbose version to show everything)
app.directive('myClass',function(){
// Runs during compile
return {
// name: '',
// priority: 1,
// terminal: true,
// scope: {}, // {} = isolate, true = child, false/undefined = no change
// controller: function($scope, $element, $attrs, $transclude) {},
// require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
restrict: 'C', // E = Element, A = Attribute, C = Class, M = Comment
// template: '',
// templateUrl: '',
// replace: true,
// transclude: true,
// compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
link: function($scope, iElm, iAttrs, controller) {
console.log('Here is your element', iElm);
// DO SOMETHING
}
};
});
here is PLUNKER...