If you're looking for a directive using querySelector, try this approach:
var desiredDirective = document.querySelector('[ng-repeat]');
To access the value of a directive, use the following method:
console.log(desiredDirective.attributes['ng-repeat'].value)
Any changes within the directive are monitored and observed. These changes should ideally stay within Angular's scope. If you need to alter them using plain JavaScript, why is that so?
You can continuously check the value using an interval. Check out this CodePen example: http://codepen.io/rias/pen/bdNgJe?editors=101
var value = 0;
function incrementValue() {
value += 1;
document.getElementById('changeme').attributes['ng-example-directive'].value = value;
}
// Simulating Angular watching for external changes
(function() {
var targetDirective = document.querySelector('[ng-example-directive]');
var pollValue = targetDirective.attributes['ng-example-directive'].value;
// Polling for changes
setInterval(function() {
var newValue = targetDirective.attributes['ng-example-directive'].value;
if (newValue != pollValue) {
pollValue = newValue;
alert(pollValue);
}
}, 100);
}());
<body ng-app>
<section ng-example-directive="1" id="changeme">
<button onclick="incrementValue()">Increase Value</button>
</section>
</body>