Let's dive right in. Imagine this as my specific instruction:
appDirectives.directive('myDirective', function () {
return{
restrict: 'A',
templateUrl: 'directives/template.html',
link: function (scope, element, attr) {
// potential access to DOM within the template through element or attr
}
};
});
Here is the corresponding template design:
<div class='col-md-12 videoholder' id="sliderContainer">
<canvas id="myCanvas"></canvas>
<div class="myLangaugesholder"></div>
</div>
I used to resort to this method (though advised against in Angular):
document.getElementById('myCanvas').style.opacity = 0.6;
The Question at Hand
How can I target the ID (e.g., myCanvas) within a directive without relying on jQuery? Attempts with the element parameter only led me to the
<div data-myDirective></div>
. Suggestions for Best Practices and Code Samples would be greatly appreciated!