我正在创建一个非常基本的angularjs应用程序。以下是我的html页面的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>antimiss</title>
</head>
<body ng-app="antimissApp" ng-controller="dataController">
<span>{{$scope.cache.cycles["6330"].cycleId}}</span>
<script type="text/javascript">
angular.module("antimissApp.services", []).factory(
"antimissService", function($http) {
var cache = {};
cache.getCache = function() {
return $http({
method: 'GET';
url: 'http://localhost:8080/antimiss/resources/rest/get'
});
}
return cache;
});
angular.module("antimissApp.controllers", []).controller(
"dataController", function($scope, antimissService) {
$scope.cache = {};
$scope.testCycle = null;
$scope.by = null;
$scope.user = null;
$scope.component = null;
antimissService.getCache().success(function(data, status, headers, config) {
$scope.cache = data;
})
});
angular.module('antimissApp', [ 'antimissApp.controllers', "antimissApp.services" ]);
</script>
<!-- Angular.js Libraries -->
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
</body>
</html>
但是在加载页面时会抛出以下错误:
17:17:09.292 Error: [$injector:modulerr] Failed to instantiate module antimissApp due to:
[$injector:nomod] Module 'antimissApp' 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.5.0/$injector/nomod?p0=antimissApp
minErr/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:68:12
module/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:2015:1
ensure@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:1939:38
module@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:2013:1
loadModules/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:4503:22
forEach@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:321:11
loadModules@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:4487:5
createInjector@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:4409:19
bootstrap/doBootstrap@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:1691:20
bootstrap@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:1712:1
angularInit@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:1606:5
@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:30423:5
trigger@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:3108:7
defaultHandlerWrapper@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:3398:3
createEventHandler/eventHandler@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:3386:9
http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=antimissApp&p1=%5B%24injector%3Anomod%5D%20Module%20'antimissApp'%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.5.0%2F%24injector%2Fnomod%3Fp0%3DantimissApp%0AminErr%2F%3C%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A68%3A12%0Amodule%2F%3C%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A2015%3A1%0Aensure%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A1939%3A38%0Amodule%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A2013%3A1%0AloadModules%2F%3C%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A4503%3A22%0AforEach%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A321%3A11%0AloadModules%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A4487%3A5%0AcreateInjector%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A4409%3A19%0Abootstrap%2FdoBootstrap%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A1691%3A20%0Abootstrap%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A1712%3A1%0AangularInit%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A1606%3A5%0A%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A30423%3A5%0Atrigger%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A3108%3A7%0AdefaultHandlerWrapper%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A3398%3A3%0AcreateEventHandler%2FeventHandler%40http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.js%3A3386%3A9%0A
minErr/<() angular.js:68
loadModules/<() angular.js:4526
forEach() angular.js:321
loadModules() angular.js:4487
createInjector() angular.js:4409
bootstrap/doBootstrap() angular.js:1691
bootstrap() angular.js:1712
angularInit() angular.js:1606
<anonymous> angular.js:30423
trigger() angular.js:3108
defaultHandlerWrapper() angular.js:3398
createEventHandler/eventHandler() angular.js:3386
1 angular.js:68:12
我目前是angularjs的新手,所以我不知道为什么模块没有加载。任何帮助将不胜感激。
答案 0 :(得分:1)
之前有语法错误!
return $http({
method: 'GET'; // <--
url: 'http://localhost:8080/antimiss/resources/rest/get'
});
替换为逗号:
return $http({
method: 'GET',
url: 'http://localhost:8080/antimiss/resources/rest/get'
});