AngularJS-访问AngularJS外部DOM元素的属性
如何获得AngularJS-访问AngularJS外部DOM元素的属性,angularjs,Angularjs,如何获得DOM元素类似于获得$scope(angular.element(element.scope()) 我需要这个,这样我就可以对插入到DOM 我的代码部分如下所示: var element = $compile(template,scope); var attrs = ? // I would do element.attrs(), // but this won't work as it does not perform normalization var
DOM
元素类似于获得$scope
(angular.element(element.scope())
我需要这个,这样我就可以对插入到DOM
我的代码部分如下所示:
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);
这对我很有用,所以你只需要知道你正在寻找的属性
console.log( angular.element(element)[0].getAttribute('class') );
实际上,这也应该起作用:
var attrs = angular.element(element)[0].attributes;
作为将来的参考,如果您包含
javascript
标记,您将吸引更多的人查看您的问题。