角度模块无法加载

时间:2016-01-03 02:18:37

标签: javascript angularjs firebase angularfire

由于某种原因,我的模块无法加载。我不明白它说:

  

未捕获错误:[$ injector:modulerr] https://docs.angularjs.org/error/ $ injector / modulerr?p0 = reddit-clone& p1 =错误:%20%5B $ injector:unpr%5D%20http:%2F%2Ferrors。 angularjs.org%2F1.2.26%2F $注射器%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20原子%20Error%20(天然)%0A%20%20%20%20原子%20http:% 2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.26%2Fangular.min.js:6:450%0A%20%20%20%20原子%20http:%2F%2Fajax.googleapis.com%2Fajax %2Flibs%2Fangularjs%2F1.2.26%2Fangular.min.js:36:202%0A%20%20%20%20原子%20C%20(HTTP:%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs% 2F1.2.26%2Fangular.min.js:34:305)%0A%20%20%20%20原子%20Object.d%20%5Bas%20invoke%5D%20(HTTP:%2F%2Fajax.googleapis.com% 2Fajax%2Flibs%2Fangularjs%2F1.2.26%2Fangular.min.js:35:6)%0A%20%20%20%20原子%20http:%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1。 2.26%2Fangular.min.js:33:394%0A%20%20%20%20原子%20R%20(HTTP:%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.26%2Fangular.min的.js:7:290)%0A%20%20%20%20原子%20E%20(HTTP:%2F%2Fajax.googleapis.com%2Fajax%2F库%2Fangularjs%2F1.2.26%2Fangular.min.js:33:207)%0A%20%20%20%20原子%20gc%20(HTTP:%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs% 2F1.2.26%2Fangular.min.js:36:309)%0A%20%20%20%20原子%20C%20(HTTP:%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.26% 2Fangular.min.js:18:170

是的,一个可爱的大https,基本上说如果你收到这个错误你的模块无法加载。请帮忙,这是我的代码:

的index.html:

<!DOCTYPE html>
<html lang="en">

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- AngularJS -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular-route.min.js"></script>
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js"></script>
    <script type="text/javascript" src="app.js"></script>
</head>
<body style="margin:20px">
  <h1 style = "text-align:center"> Reddit Clone</h1>
  <div ng-view></div>
</body>
</html>

app.js:

var app = angular.module('reddit-clone' , ['ngRoute', 'firebase'])

app.config(function($routeProvider){
  $routeProvider.when('/',{
      controller:'MainController'
      templateUrl:'main.html'
  })
          .otherwise({
      redirectTo:'/'
  })
})

app.controller('MainController', function($scope, firebase){


})

main.html中:

<h1>Hey Guys this is cool</h1>

1 个答案:

答案 0 :(得分:1)

您还需要在shell中指定ng-app

<body ng-app="reddit-clone" style="margin:20px">