有没有办法在AngularJS表达式运行时进入调试器?

时间:2017-10-17 01:47:53

标签: angularjs google-chrome-devtools

如果我选择此选项:<select name="custType" ng-model="vm.custType" ng-options="c.name.toUpperCase() as c.name for c in vm.customers"...>

当ng-options中的表达式开始运行时,有没有办法进入devtools调试器? 不同的原因
  - 我想知道表达式在网页生命周期中的运行时间   - 我想知道c.name和vm.customers的当前值    表达生命周期中的一个时间点。
   - 我还想知道在加载数据之前是否正在使用vm.customers。

2 个答案:

答案 0 :(得分:0)

在angular src代码中找到ng-options指令并放置一个断点。

ng-options

答案 1 :(得分:0)

尝试使用以下内容:

<强> HTML

 <select name="custType"
         ng-model="vm.custType"
         ng-options="c.name.toUpperCase() as c.name for debugCustomer(c) in vm.customers"
  ... ></select>

<强> JS

...

$scope.debugCustomer = function (customer) {
  console.log(customer);
  debugger;
  return customer;
}

...