gpt4 book ai didi

javascript - 在 AngularJS 上调用 jQuery 函数

转载 作者:行者123 更新时间:2023-12-02 15:39:17 24 4
gpt4 key购买 nike

如何使用 AngularJS 调用 jQuery 函数或代码?

例如,我有这个 HTML:

<iframe ng-src="{{v}}"></iframe>

还有我的 Controller :

angular.module("myApp", [])
.controller("AppCtrl", function($scope, myService) {
$scope.myScope = function() {

$('iframe').pluginCall();

myService.myFunc(function( data ){
$scope.myVar = 'Hey';
[...]
});
};
});

所以,我想运行$('iframe').css('opacity','.5');为我退还的东西。

我该怎么做?

Check it!

最佳答案

我认为你不应该这样做,而是使用 Angular 方式:

<iframe ng-src="{{v}}" ng-style="{ opacity: '.5' }"></iframe>

如果你确实想获取 Controller 内的对象,可以使用 Angular 的元素查询:

angular.element(document.querySelector('iframe')).css('opacity','.5';

关于javascript - 在 AngularJS 上调用 jQuery 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32696171/

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