I am trying to incorporate a Google chart using an Angular directive on a webpage and I want to add an attribute to the element that is created after it has loaded. What is the most effective way to ensure that the element exists before adding the attribute?
After exploring various sources, it seems like the directive I have should work but it's not functioning as expected:
.directive('vdfWidgetGoogleChart', ['$timeout', function ($timeout) {
return {
restrict: 'E',
//replace: true,
templateUrl: 'widgetgooglechart.html',
link: function ($scope, elem, attrs) {
function addTabIndex () {
elem.find('svg').attr({tabindex: -1});
}
$timeout(addTabIndex);
},
scope: {
chartObject: '='
}
}