AngularJS Error: [$injector:nomod]

AngularJS Error: [$injector:nomod]

本文关键字:nomod injector Error AngularJS      更新时间:2023-09-26

奇怪的是,该模块在Firefox中完美加载。

在Chrome中,模块有时会加载(在打开和关闭刷新时),并且似乎是唯一出现以下控制台错误的浏览器。

错误:[$injector:nomod]模块"myApp"不可用!您拼错了模块名称或忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。

var myApp =  angular.module('myApp', []);
function MyController($scope, $http){
    $http.get("http://localhost/json").success(function(response){
        $scope.customers = response;
    });
});
myApp.controller('MyController', MyController);`

我认为"。success()"要避免承诺,应该使用.then(),这里有一个解释它的链接http://www.codelord.net/2015/05/25/dont-use-$https成功/

它是随机工作的,因为promise在您的案例中没有使用