角JS:从jQuery的访问$范围 [英] angular js: accessing $scope from jQuery

查看:101
本文介绍了角JS:从jQuery的访问$范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有几个类似这样的问题的计算器。我知道。尝试了所有的答案,但仍没有运气。
我的HTML:

There are several questions like this in stackoverflow. I know. Tried all the answers, but still no luck. My html :

    <div class="headline" id="headline-game">
        {{gameContent.headline}}
    </div>

jQuery的:

jQuery:

    var country = $("#headline-game").scope().headline;
    alert(country);

但我得到的而不是我的范围不确定。谁能帮我?我不想改变的范围,只是访问它。

But I got undefined, instead of my scope. Can anyone help me? I don't wanna change the scope, just accessing it.

推荐答案

角增加了一个全球性的变量到你的窗口。

Angular adds a global angular variable to your window.

所以,你可以做这样的事情:

So you can do something like this:

angular.element("#headline-game").scope().gameContent.headline;

这篇关于角JS:从jQuery的访问$范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆