简体   繁体   English

如何在AngularJS上下文中使用Google Chrome开发者工具在HTML代码中设置断点?

[英]How to set a breakpoint in HTML-code with Google Chrome Developer Tool in the context of AngularJS?

I have the following line of HTML-code ie: 我有以下一行HTML代码,即:

<button ng-click="round.won=true" ng-class="{'active':round.won && !adjustedYesNo}" class="button button-outline">Gewonnen</button>

It is not clear to me, which function has been called in which file when having clicked a button and fired the ng-click-event. 我不清楚,当单击按钮并触发ng-click-event时,哪个函数已在哪个文件中调用。

So I wonder how to set a breakpoint in Google Chrome Developer Tool next to ng-click="round.won=true" in order to jump into the related Javascript-function/file? 因此,我想知道如何在ng-click="round.won=true"旁边的Google Chrome开发者工具中设置断点,以跳至相关的Javascript函数/文件吗?

You cannot set breakpoints on HTML code. 您不能在HTML代码上设置断点。 However if your code was something like below: 但是,如果您的代码如下所示:

HTML 的HTML

 <button ng-click="winRound()" ng-class="{'active':round.won && !adjustedYesNo}" class="button button-outline">Gewonnen</button> 

Controller 控制者

app.controller(function($scope) {
  $scope.winRound = function() {
     $scope.round.win = true;
  }
});

Then you could have set a breakpoint inside the winRound function in the JS file. 然后,您可以在JS文件的winRound函数内设置一个断点。 But make sure that your JS code (controller) is places in a separate JS file and not inside the script tag in HTML. 但是请确保将您的JS代码(控制器)放在单独的JS文件中,而不是在HTML的script标签中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM