Reputation: 8663
Im trying to write some fairly simple JS.
I have a rang of angular controllers defined on my HTML pages, e.g:
<div ng-controller="Ctrl1">
// My code
</div>
How would i go about writing some vanilla JS/jQuery on page load, to detect if 'ng-controller' exists?
Thanks
Upvotes: 0
Views: 104
Reputation: 78535
You can use a simple attribute querySelector:
if(document.querySelector("[ng-controller]")) {
// ng-controller tag exists
}
Upvotes: 1