0

In my angularjs application on ng-click on a button, I have

$scope.getItems = function() {
    var matchedElements = angular.element(document).find('.main_tabSet');
    console.log(matchedElements.length);
}

which is working fine.

Now there are few bootstrap classes which are injected below main_tabSet, which I am trying to access in ng-click as

 var matchedElements = angular.element(document).find('.main_tabSet .nav .nav-tabs');

but this is not returning the elements. What is the right way of accessing elements using nested classes?

Madasu K
  • 1,813
  • 2
  • 38
  • 72
  • `find()` is only to look up by tag names anyway not classes // id\s.. Here is the docs with your answer too.. : https://docs.angularjs.org/api/ng/function/angular.element – Pogrindis Jan 19 '16 at 14:15
  • Worth noting that you can add full jquery into the page, in which case your selector should then work – Rhumborl Jan 19 '16 at 14:26
  • Possible duplicate of [AngularJS: How to .find using jqLite?](http://stackoverflow.com/questions/17283697/angularjs-how-to-find-using-jqlite) – Rhumborl Jan 19 '16 at 14:30

1 Answers1

2

You want to use querySelector like so :

var matchedElements = angular.element(document.querySelector('.main_tabSet .nav .nav-tabs'));

Elemenet documentation

From their own docs on find() : f

find() - Limited to lookups by tag name

And very much related question :

AngularJS: How to .find using jqLite?

Community
  • 1
  • 1
Pogrindis
  • 7,755
  • 5
  • 31
  • 44