我遇到了错误
Microsoft JScript runtime error: [$injector:modulerr] http://errors.angularjs.org/1.3.0-beta.11/$injector/modulerr?p0=MyApp&p1=%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.3.0-beta.11%2F%24injector%2Fnomod%3Fp0%3DMyApp
我怎样才能解决这个问题?我使用的是AngularJS
AngularJS v1.3.0-beta.11
的最新版本。
这是我的index.htm
代码:
<!DOCTYPE html>
<html lang="en" ng-app="MyMVC">
<head>
<meta http-equiv="x-ua-compatible" content="IE=9" charset="UTF-8"/>
<title></title>
<script src="lib/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="JSON3.min.js" type="text/javascript"></script>
<script src="lib/angular/angular.min.js" type="text/javascript"></script>
<script src="lib/angular/angular-route.min.js" type="text/javascript"></script>
<script src="lib/angular/app.js" type="text/javascript"></script>
<script src="lib/angular/controllers.js" type="text/javascript"></script>
</head>
<body>
<div ng-view></div>
这是我的app.js
代码
var myApp = angular.module('MyMVC', [
'ngRoute',
'logController'
]);
myApp.config(['$routeProvider', function($routeProvider)]{
$routeProvider.
when('/list', {
templateUrl: 'partials/list.htm',
controller: 'ListController'
}).
otherwise({
redirectTo: '/list'
});
});
这是我的controller.js
代码:
var logController = angular.module('logController', []);
logController.controller('ListController', function ($scope, $http) {
$http.post('testws.asmx/GetLogs', {
headers: { 'Content-Type': 'application/json; charset=utf-8' }
}).success(function (data) {
$scope.logs = data.d;
$scope.orderRecord = 'RecordId';
})
.error(function (err) {
$scope.error = err["Message"];
});
});
任何建议都将是一个很大的帮助。谢谢!
更新:将角度js缩小版本更改为不 这是新的错误提示:
Microsoft JScript runtime error: [$injector:modulerr] Failed to instantiate module MyMVC due to:
[$injector:nomod] Module 'MyMVC' 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.
http://errors.angularjs.org/1.3.0-beta.11/$injector/nomod?p0=MyMVC
http://errors.angularjs.org/1.3.0-beta.11/$injector/modulerr?p0=MyMVC&p1=%5B%24injector%3Anomod%5D%20Module%20'MyMVC'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.3.0-beta.11%2F%24injector%2Fnomod%3Fp0%3DMyMVC
答案 0 :(得分:1)
没有实际的例子,调试真的不可能 一些提示:
错误是指无法实例化名为MyApp的模块。仔细检查您的标记是否与您的javascript具有相同的ng-app。
如果在查看异常时切换到非缩小版角度,它也可以帮助调试。
答案 1 :(得分:0)
myApp.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/list', {
templateUrl: 'partials/list.html',
controller: 'ListController'
}).
otherwise({
redirectTo: '/list'
});
}]);
解决问题,我只是错放了]
并将其移至最后。感谢所有帮助: - )