angular.js:38未捕获错误:[$ injector:modulerr]

时间:2016-04-26 08:45:04

标签: javascript angularjs

下面是代码,我已经包含了角度文件,甚至是角度路由,但它仍然会给出相同的错误。我正在尝试一个非常简单的角度代码,但它仍然给我这个错误,有人能告诉我我在哪里错了。感谢。

<title>Login</title>
<div></div>
<div class="middle-box text-center loginscreen animated fadeInDown">
<div>
<div></div>
<h3>Welcome to Login</h3>
</div>
<div ng-app="myApp" ng-controller="LoginCtrl">
<a ng-show="failedattempt">
  <small>Wrong username or password</small></a>
<form role="form" class="m-t">
  <div class="form-group">
    <!--input(type='hidden', name='_csrf', value='<%= csrfToken %>')-->
    <input type="email" placeholder="Username" ng-model="user.username" required="true" class="form-control"/>
  </div>
  <div class="form-group">
    <input type="password" placeholder="Password" ng-model="user.password" required="true" class="form-control"/>
  </div>
  <button type="submit" id="submit" ng-click="submit()" class="btn btn-primary block full-width m-b">Login</button><a href="/login/forgot/"><small>Forgot password?</small></a>
</form>
</div>
</div>
<script type="text/javascript">
var app = angular.module("myApp", ['$scope']);
app.controller("LoginCtrl", function($scope){
var url = "/login/";
$scope.failedattempt=false;
$scope.user = {
username:"",
password:""
};
$scope.submit = function($scope){
  $scope.failedattempt = true;
}});
</script>

1 个答案:

答案 0 :(得分:4)

您可以对app

使用以下定义吗?
var app = angular.module("myApp", []);

无需包含&#39; $ scope&#39;在定义中。