我是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代码,正如我现在面临很多困难在了解控制台错误信息。 截图控制台:
如果在本地调试不使用分档。 – Chandermani 2014-10-01 06:28:53