2013-05-10 53 views
5

我如何獲得DOM元素Attributes類似的方式(外角)我得到$scope(angular.element(element).scope())AngularJS - 訪問角度外的DOM元素的屬性

我需要這個,所以我可以說被插入DOM

某些元素上使用$animator服務我的代碼的部分看起來像:

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

以供將來參考,如果您包含'javascript'標記,您將會讓更多人看到您的問題。 – 2013-09-13 19:40:11

回答

2

這爲我工作,所以你只需要知道你正在尋找...

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

屬性其實這應該工作,然後過:

var attrs = angular.element(element)[0].attributes;