未捕获的错误:[$ injector:modulerr] http://errors.angularjs.org/1.2.16

时间:2014-04-22 07:02:41

标签: angularjs spring-mvc

我添加此行

<html lang="en" ng-app="myApp">

我收到此错误

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=mctApp&p1=Error%3A…rg%2F1.2.16%2F%24injector%2Fnomod%3Fp0%3DmctApp%0A%20%20%20%20at%20Error%2...<omitted>...1) 

我添加了这些脚本

<script type="text/javascript" src="/resources/js/lib/angular.min.js"></script>
<script type="text/javascript" src="/resources/js/lib/angular-route.min.js"></script>
<script type="text/javascript" src="/resources/js/lib/angular-resource.min.js"></script>

Javascript应用代码

angular.module('myApp', []).config(mctRouter);

function mctRouter($routeProvider) {

    $routeProvider
        .when('/', {
            templateUrl: 'home.jsp'
        });
}

2 个答案:

答案 0 :(得分:2)

您忘了将ngRoute注入您的应用。像

一样注入它
angular.module('myApp', ['ngRoute']).config(mctRouter);

答案 1 :(得分:1)

$route, $routeParams and ngView已从核心angular.js中撤出 到angular-route.js / ngRoute模块。因此,您现在需要加载 angular-route.js文件并定义对ngRoute模块的依赖。

在:

<script src="angular.js"></script>
.....
var myApp = angular.module('myApp', ['someOtherModule']);

后:

<script src="angular.js"></script>
<script src="angular-route.js"></script>
.....
var myApp = angular.module('myApp', ['ngRoute', 'someOtherModule']);

更多详情here