Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - accessing Attributes of a DOM element outside Angular

Tags:

angularjs

How do I get DOM element Attributes similar way (outside angular) I get $scope (angular.element(element).scope()) ?

I need this so I can use $animator service on some element that is being inserted into DOM

the part of my code would look like:

var element = $compile(template,scope);
var attrs = ? // I would do element.attrs(), 
              // but this won't work as it does not perform normalization
var animation = $animator(scope,attrs);
animation.enter(element,parent);
like image 623
g00fy Avatar asked Nov 02 '22 22:11

g00fy


1 Answers

this worked for me so you'll just need to know the attributes you're looking for...

console.log( angular.element(element)[0].getAttribute('class') );

actually this should then work too:

var attrs = angular.element(element)[0].attributes;
like image 135
btm1 Avatar answered Nov 11 '22 12:11

btm1