I have a simple directive and I'd like to access one of its inner DOM element to add a class to it.
div(my-directive)
div
// some html
span.myDiv
| some text
My HTML has much more elements than this so accessing .myDiv via the .childen() method is quite tedious.
I've tried the following which doesn't work:
.directive('myDiv', ['$compile', function($compile) {
return {
restrict: 'A',
link: function(scope, element) {
var el = element[0].getElementsByClassName('myDiv')
angular.element(el).addClass('myAwesomeClass')
$compile(el)(scope)
}
}
}])
How can I do this?
Many thanks