我正在尝试创建一个简单的Angular App,但是每次我在应用程序中加载页面时都会出现以下错误。
我有一个主页,我使用一个菜单访问角度页面,该菜单通过jQuery ajax调用加载页面内容。当我这样做的时候,即使存在myapp
并且包含了所有必需的文件,我仍然会收到以下错误。
请注意,当我直接在浏览器中访问页面的URL时,它工作正常......只有当我使用ajax调用从我的主页访问此角度页面时才会发生这种情况。
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=myapp&p1=Error%3A%2…jquery%2F2.2.4%2Fjquery.min.js%3A2%3A2640)%2C%20%3Canonymous%3E%3A20%3A359)
`
Failed to instantiate module myapp due to:
Error: [$injector:nomod] http://errors.angularjs.org/1.5.7/$injector/nomod?p0=myapp
at Error (native)
at eval (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:6:412)
at eval (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:25:72)
at b (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:24:115)
at eval (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:24:358)
at eval (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:39:374)
at r (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:7:355)
at g (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:39:222)
at db (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:43:246)
at Bc.c (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:2:2640), <anonymous>:20:359
`
位指示 `
var myapp=angular.module('myapp',[]);
myapp.controller('UserConfigController',['$scope','$http', function($scope,$http){
$http.get('/runquery/getdata/userconfig').success(function(data){ $scope.usrConf=data; });
}]);
`
有角度代码的网页
<script src="${pageContext.request.contextPath}/s/xxxx_static/js/thirdParty/angular.min.js"></script>
<script src="${pageContext.request.contextPath}/s/xxxx_static/js/controllers/queryContorllers.js"></script>
</head>
<body>
<div ng-app="myapp">
<input type="text" ng-model="name">
<h2>Welcome {{name}}</h2>
<div ng-controller="UserConfigController">
<div ng-repeat="it in usrConf">
<h1>{{it.propertyName}}</h1>
</div>
</div>
</div>