Microsoft JScript runtime error: [$injector:modulerr] in AngularJS v1.3.0-beta.11

人盡茶涼 提交于 2019-12-24 06:39:12

问题


I encountered error of

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

How can I possibly fix this issue? I am using the latest version of AngularJS which is AngularJS v1.3.0-beta.11.

Here is my index.htm code:

<!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>

Here is my app.js code

    var myApp = angular.module('MyMVC', [
    'ngRoute',
    'logController'
]);

myApp.config(['$routeProvider', function($routeProvider)]{
    $routeProvider.
    when('/list', {
        templateUrl: 'partials/list.htm',
        controller: 'ListController'
    }).
    otherwise({
        redirectTo: '/list'
    });
});

And here is my controller.js code:

    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"];
    });
});

Any suggestions will be a big help. Thanks!

UPDATE: change angular js minified version to not Here is the new error prompt:

    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

回答1:


Not really possible to debug without an actual example.
A couple of hints:

The error refers to not being able to instantiate a module called MyApp. Double check your markup has the same ng-app as your javascript.

Also it can help with debugging if you switch to the non minified version of angular while looking at exceptions.




回答2:


 myApp.config(['$routeProvider', function($routeProvider){
    $routeProvider.
    when('/list', {
        templateUrl: 'partials/list.html',
        controller: 'ListController'
    }).
    otherwise({
        redirectTo: '/list'
    });
}]);

solve the issue, i just misplaced the ] and move it to the end. Thanks for all the help :-)



来源:https://stackoverflow.com/questions/24114556/microsoft-jscript-runtime-error-injectormodulerr-in-angularjs-v1-3-0-beta-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!