小编Ves*_*vic的帖子

在AngularJS指令中使用Jquery有什么好主意?

您可以在下面看到我的指令代码.

我的问题是:"我可以使用jquery指令吗?这是一个好主意吗?如果不是为什么?"

outsource.directive('dedicated', function(){

        return {
           restrict: 'E',
           link: function(scope, element, attribute){

                 $("#klik").click(function(){
                    alert('works');
                 });

           },

           replace: true,
           templateUrl: 'src/app/components/views/dedicated-prices.html'
        };
    });
Run Code Online (Sandbox Code Playgroud)

这个代码有效.

javascript jquery angularjs angularjs-directive

11
推荐指数
1
解决办法
1万
查看次数

在javascript中检测同一应用程序打开的多个chrome选项卡

有没有办法检测是否打开了同一应用程序的多个浏览器选项卡。

假设我有 www.test.com 并且我打开了这个网站的 4 个标签。

有没有办法检测在 JavaScript 中打开了多个选项卡?

javascript google-chrome angularjs

5
推荐指数
1
解决办法
3355
查看次数

如何使用Jquery将click事件附加到AngularJS指令?

我制作了AngularJS指令,我在我的主页上加载,我也有 JQuery文件,我alert('it works')<p> Click </p>单击元素时调用.这是一个例子.

/*
 * This is the directive
 */

outsource.directive('mydirective', function() {
    return {
        restrict: 'E',
        link: function(scope, element, attribute) {
            // Link
        },
        replace: true,
        templateUrl: 'src/app/components/views/directive.html'
    };
});
Run Code Online (Sandbox Code Playgroud)

directive.html文件

<p id="clicked"> Click </p>
Run Code Online (Sandbox Code Playgroud)

jquery函数

$(document).ready(function() {
    $("#clicked").click(function() {
        alert('it works');
    });
});
Run Code Online (Sandbox Code Playgroud)

对于我真正的问题,这只是一个简单的问题.我注意到angular指令的加载速度比触发警报消息的函数要慢.因为我的选择器没有选择任何东西$("#clicked").

*我应该如何使用jquery的angular指令?除了使用jqlite之外,解决这个jquery-angular问题的正确方法是什么?*

javascript jquery angularjs angularjs-directive

1
推荐指数
1
解决办法
1644
查看次数