2014-10-01 62 views
2

我是Angular JS的新手。我的第一個問題是如何理解Angular JS中來自控制檯的錯誤消息。我寫了這段代碼來匹配密碼。它在控制檯上拋出錯誤,但它工作正常。它有線。我無法從這些控制檯消息中理解任何內容。任何人都可以請我指出爲什麼我在控制檯上收到錯誤消息。如何理解Angular JS中的控制檯錯誤消息?任何工具?

var sampleApp = angular.module("sampleApp",[]); 
 
\t \t \t sampleApp.controller('sampleCtrl', ['$scope', function($scope){ 
 
\t \t \t \t 
 
\t \t \t }]); 
 
\t \t \t sampleApp.directive('pwCheck', [function(){ 
 
\t \t \t \t // Runs during compile 
 
\t \t \t \t return { 
 
\t \t \t \t \t 
 
\t \t \t \t \t require: 'ngModel', // Array = multiple requires, ? = optional,^= check parent elements 
 
\t \t \t \t \t 
 
\t \t \t \t \t link: function($scope, iElm, iAttrs, controller) { 
 
\t \t \t \t \t \t var password1 = iAttrs.ngModel; 
 
\t \t \t \t \t \t var password2 = iAttrs.pwCheck; 
 
\t \t \t \t \t \t $scope.$watch('[password1, password2]', function(newValue, oldValue){ 
 
\t \t \t \t \t \t \t controller.$setValidity('pwmatch', $scope[password1] === $scope[password2]); 
 
\t \t \t \t \t \t }); 
 
\t \t \t \t \t } 
 
\t \t \t \t }; 
 
\t \t \t }]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<html ng-app="sampleApp"> 
 
\t <head> 
 
\t </head> 
 
\t <body ng-controller="sampleCtrl"> 
 
\t \t <form name="myForm"> 
 
\t \t \t <label for="pw1">Set a password:</label><br /> 
 
\t \t \t <input type="password" id="pw1" name="pw1" ng-model="pw1" /><br /> 
 
\t \t \t <label for="pw2">Confirm the password:</label><br /> 
 
\t \t \t <input type="password" id="pw2" name="pw2" ng-model="pw2" pw-check="pw1" /> 
 
\t \t \t <div class="msg-block" ng-show="myForm.$error"> 
 
\t \t \t \t <span class="msg-error" ng-show="myForm.pw2.$error.pwmatch">Passwords don't match.</span> 
 
      </div> 
 
\t \t </form> 
 
\t </body> 
 
</html>

有沒有簡單的方法/工具來調試角度JS代碼,正如我現在面臨很多困難在瞭解控制檯錯誤信息。 截圖控制檯: enter image description here

+3

如果在本地調試不使用分檔。 – Chandermani 2014-10-01 06:28:53

回答

0

如果它是你的文件中的錯誤比角會給你的第一行錯誤(最後2位數)問題代碼的位置。以下幾行是調用堆棧。如果這是您在角碼中導致的錯誤,那麼第一行是指向描述錯誤的角度站點的鏈接。

https://docs.angularjs.org/error/$rootScope/infdig - 這是你的錯誤。你以某種方式在摘要循環中造成無限循環。

編輯:和JanR建議使用Chrome中Batarang它是更適合的角度

相關問題