我正试图在我的网络应用中获得角度。它以前工作,但现在突然停止工作,我得到这个错误:
未捕获错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.0-rc.2/ $注射器/ modulerr P0 = MyApp来&安培; P1 =错误... pis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0-rc.2%2Fangular.min.js%3A20%3A463)
Angular Code:
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>
答案 0 :(得分:1)
var myApp = angular.module("myApp", ['']);
你试图在你的依赖项中注入一个空字符串,如果你删除它应该再次工作:
var myApp = angular.module("myApp", []);