当前位置: 动力学知识库 > 问答 > 编程问答 >

AngularJS - accessing Attributes of a DOM element outside Angular

问题描述:

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);

网友答案:

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;
分享给朋友:
您可能感兴趣的文章:
随机阅读: