如何访问$范围变量角度从控制台铬 [英] how to access $scope variable in angular from chrome console

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

问题描述

如何从Chrome的控制台访问范围的变量部件

how to access the scope variable widgets from chrome's console

function MyCntrl($scope) {
      $scope.widgets = [
                  {text:'Widget #1', datarow:1, datacol:1, datasizex:3, datasizey:3},
                  {text:'Widget #2', datarow:2, datacol:1, datasizex:3, datasizey:3},
                  {text:'Widget #3', datarow:1, datacol:2, datasizex:3, datasizey:3},
                  {text:'Widget #4', datarow:2, datacol:2, datasizex:3, datasizey:3}
      ];

类似$ scope.widgets干脆不工作在控制台!

something like $scope.widgets simply doesnt work in the console!

推荐答案

的范围被绑定到DOM,所以你需要抓住一个元素,并使用一些棱角code得到的范围。

The scope is bound to the DOM so you need to grab an element and use some angular code to get the scope.

您最好的选择是让该控制器绑定到一个元素,并看看在该范围之内。

Your best bet is to get an element that the Controller is bound to and have a look at the scope on that.

下面就是答案
<一href=\"http://stackoverflow.com/questions/13743058/how-to-access-the-angular-scope-variable-in-browsers-console\">how访问角$范围的变量在浏览器控制台

这篇关于如何访问$范围变量角度从控制台铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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