我试图在我的Web应用程序中进行有角度的工作。它以前曾在工作,但现在突然停止工作,并且出现此错误:
未捕获的错误:[$ injector:modulerr]
http://errors.angularjs.org/1.5.0-rc.2/ $ injector / modulerr?p0 = myApp&p1 = Error ... pis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0-rc.2%2Fangular.min.js%3A20%3A463)
角度代码:
var myApp = angular.module("myApp", ['']);
myApp.factory("DataService", ["$http", function ($http){
var getData = function(callback){
var url = 'api-url-returns-json';
$http.get(url).success( function(response) {
callback(response);
});
}
return {
getDashboardData: getData
}
}]);
myApp.factory("ClockProvider", ["$interval", function ($interval){
var time = null;
var runOnTick = function(tick, callback){
var myClock = $interval(function(){
time = new Date();
m = time.getMinutes();
s = time.getSeconds();
var array = tick;
var arrayLength = array.length;
for (var i = 0; i < arrayLength; i++) {
var value = array[i];
if (value == m) {
callback();
}
}
}, 2000);
}
return {
run: runOnTick
}
}]);
myApp.controller("dashboardController", ["$scope", "DataService", "ClockProvider", function ($scope, DataService, ClockProvider){
DataService.getDashboardData(function(data){
$scope.dashboard = data;
});
var intervals = ["0", "30"];
ClockProvider.run(intervals, function(){
DataService.getDashboardData(function(data){
$scope.dashboard = data;
});
});
}]);
总结HTML:
<html ng-app="myApp">
</head></head>
<body>
<div ng-controller="dashboardController">
<span>{{ dashboard.status }}</span>
</div>
</body>
</html>
最佳答案
var myApp = angular.module("myApp", ['']);
您正在尝试在依赖项中插入一个空字符串,如果删除该字符串应可以再次使用:
var myApp = angular.module("myApp", []);
关于javascript - Angular 模块无法正确加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35362055/