Lior Lior - 1 year ago 176
AngularJS Question

AngularJS: How to .find using jqLite?

I'm trying to remove jquery from my Angular.js app in order to make it lighter, and put Angular's jqLite instead. But the app makes heavy use of find('#id') and find ('.classname'), which are not supported by jqLite, only 'tag names' (as per documentation)

wondered what do u feel would be the best approach to change it. One approach I thought about is to create custom HTML tags. for example:

<span class="btn btn-large" id="add-to-bag">Add to bag</span>


<a2b style="display:none;"><span class="btn btn-large" >Add to bag</span></a2b>





Any thoughts? other ideas?



Answer Source

Essentially, and as-noted by @kevin-b:

// find('#id')

//find('.classname'), assumes you already have the starting elem to search from

Note: If you're looking to do this from your controllers you may want to have a look at the "Using Controllers Correctly" section in the developers guide and refactor your presentation logic into appropriate directives (such as <a2b ...>).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download