gpt4 book ai didi

AngularJS - 在 Angular 之外访问 DOM 元素的属性

转载 作者:行者123 更新时间:2023-12-04 21:18:50 24 4
gpt4 key购买 nike

我如何获得 DOM元素 Attributes 类似的方式(外 Angular )我得到 $scope (angular.element(element).scope()) ?

我需要这个所以我可以使用 $animator正在插入到 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;

关于AngularJS - 在 Angular 之外访问 DOM 元素的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16473192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com