serge
serge

Reputation: 15239

How, with Angular's jQueryLite, to find an element by id?

I need to know if an element id="Tags" is present in my Angular's controller document....

So I do the check (immediate window debug results):

?angular.element($document).find("#Tags").length
0
?$("#Tags").length
1
?angular.element($document.querySelector('#Tags'))
VM1119:1 Uncaught TypeError: $document.querySelector is not a function

Just wondering, how to make jQueryLite to find an element by id...

Upvotes: 0

Views: 60

Answers (1)

Stephen Thomas
Stephen Thomas

Reputation: 14053

You can't. But you can use vanilla JavaScript

var el = document.getElementById("Tags");

And you can turn the result into a jqLite selection

angular.element(el);

Upvotes: 3

Related Questions