在標題中提到的NetBeans錯誤中運行AngularJS應用程序後出現。我看不到堆棧超載的任何點,因爲您看到我只初始化了兩個用於登錄表單處理的變量(我在我的AngularJS冒險開始時)。它可能是一些硬件問題,或者我在這裏做了一些無意識的錯誤?AngularJS - RangeError:'應用程序啓動後超出最大調用堆棧大小
錯誤:
RangeError: Maximum call stack size exceeded
at c (public_html/bower_components/angular/angular.min.js:115:232)
at http://localhost:8383/LoginJS/bower_components/angular/angular.min.js:115:506
at q (public_html/bower_components/angular/angular.min.js:7:355)
at Object.error (public_html/bower_components/angular/angular.min.js:115:475)
at http://localhost:8383/LoginJS/bower_components/angular/angular.min.js:89:12
at ra (public_html/bower_components/angular/angular.min.js:69:475)
at xa (public_html/bower_components/angular/angular.min.js:58:270)
at xa (public_html/bower_components/angular/angular.min.js:58:402)
at ba (public_html/bower_components/angular/angular.min.js:56:264)
at A.link (public_html/bower_components/angular-route/angular-route.min.js:7:224) (13:52:05:371 | error)
app.js
angular.module('myapp', ['ngRoute']).config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'index.html'
})
.when('/dashboard', {
templateUrl: 'dashboard.html'
})
.otherwise(({
redirectTo: '/'
}));
});
loginCtrl.js
angular.module('myapp').controller('loginCtrl', function($scope, $location) {
$scope.submit = function() {
var username = $scope.username;
var password = $scope.password;
if($scope.username == 'admin' && $scope.password == 'admin') {
$location.path('/dashboard');
}
};
})
的index.html
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="bower_components/angular/angular.min.js" type="text/javascript"></script>
<script src="bower_components/angular-route/angular-route.min.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<script src="scripts/controllers/loginCtrl.js" type="text/javascript"></script>
</head>
<body ng-app="myapp">
<div ng-view></div>
<div ng-controller="loginCtrl">
<form action="/" id="login">
Username: <input type="text" name="username" id="username" ng-model="username"><br>
Password: <input type="password" name="password" id="password" ng-model="password"><br>
<button type="button" ng-click="submit()">Login</button>
</form>
</div>
</body>
</html>
dashboard.html
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="bower_components/angular/angular.min.js" type="text/javascript"></script>
<script src="bower_components/angular-route/angular-route.min.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
</head>
<body ng-app="myapp">
<div ng-view></div>
some text
</body>
</html>
我修改dashboard.html根據您的建議和錯誤沒有消失 –
你有任何功能,做循環參考?並可以嘗試通過將登錄信息轉移到另一個html頁面,如'login.html'和'/''路徑將該頁面作爲'templateUrl'而不是'index.html' @Mike –
更新可能會回答,它應該是工作@Mike –