Madasu K
Madasu K

Reputation: 1863

getting angular element using nested classes

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?

Upvotes: 0

Views: 1380

Answers (1)

Pogrindis
Pogrindis

Reputation: 8121

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?

Upvotes: 2

Related Questions