0
所以我得到了下面的错误和提示:角模块未注册正确
Failed to instantiate module stable due to:
Error: [$injector:nomod] http://errors.angularjs.org/1.4.9/$injector/nomod?p0=stable
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:6:416
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:24:186
at b (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:23:252)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:23:495
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:38:153
at n (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:7:355)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:38:1)
at db (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:41:272)
at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:19:463
Module 'stable' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
所以我试图找出为什么登记不工作,但我已经没有运气远。
我在我的.js得到这个
/*global angular*/
var stable = angular.module('stable',[]);
stable.controller('mainController', function($scope) {
$scope.master = {};
$scope.login = function() {
var loginAttempt = {
"_userName": $scope.userName;
"_password": $scope.userPassword;
};
console.log(loginAttempt);
};
$scope.create_account = function(user) {};
});
,并在我的我的顶级HTML标记的“NG-应用=”稳定“”属性。我错过了什么?
HTML代码在这里:
<!DOCTYPE html>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular-route.js"></script>
<html lang="en" >
<br xmlns="http://www.w3.org/1999/html">
<head>
<title>User Login</title>
<style>
body {
background: rgb(210, 77, 87) !important;
}
</style>
</head>
<body ng-app="stable" ng-controller="mainController">
<i><span style="color:#FFFFFF; font-family:Segoe UI Black,serif; font-size:50px; margin-left: 1%; margin-top:1%;">STABLE</span></i>
<!-- onclick="location.href = 'http://localhost:63342/AngularJS/AccountPage.html'" removed from Create Account-->
<button type="button" ng-click="create_user(user)" class="btn btn-primary btn-lg" name="create_user_button" style="float:right; margin-right:2.5%; margin-top:1%;">Create Account</button><br>
<div style="text-align: center;">
<br><br><br><br>
<b><span style="color:#FFFFFF; font-size: 32px;">Hello! Please Sign In.</span></b><br><br>
<input style="font-size:28px;" ng-model="userName" type="text" name="username" id="id_username" placeholder="Username" size="32" maxlength="16" /><br><br>
<input style="font-size:28px;" ng-model="userPassword" type="password" name="password" id="id_password" placeholder="Password" size="32" maxlength="16"/><br>
<a href="http://localhost:63342/AngularJS/PasswordPage.html" style="color:#FFFFFF; font-size: 16px;">Forgot Password?</a>
<br><br>
<!-- onclick="location.href = 'http://localhost:63342/AngularJS/MainPage.html'" removed from button -->
<button type="submit" ng-click="login()" class="btn btn-primary big-btn btn-lg" name="login_button" >Login</button>
</div>
</body>
</html>
我已经添加了HTML。 js文件与当前HTML文件位于同一目录 – Pedro
@Pedro您可以测试以确定角度是否正确设置的一种方法是在您的html的某处包含一个表达式。例如在你的身体标签。在你的身体标记后面加{{1 + 2}},如果角度正在工作,它应该显示一个3.如果你在查看html时看到的是{{1 + 2}},那么角度设置不正确。在您尝试其他任何事情之前,我发现这对确保角度工作最初很有帮助。 – sbrand83