ajgisme
ajgisme

Reputation: 1765

Angular module not loading properly

I am trying to get angular working in my web app. It was working before, but now has suddenly stopped working and I get this error:

Uncaught Error: [$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)

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;
        });
    });
}]);

Summarised HTML:

<html ng-app="myApp">
    </head></head>
    <body>
        <div ng-controller="dashboardController">
            <span>{{ dashboard.status }}</span>
        </div>
    </body>
</html>

Upvotes: 0

Views: 113

Answers (1)

Martijn Welker
Martijn Welker

Reputation: 5605

var myApp = angular.module("myApp", ['']);

You're trying to inject an empty string in your dependancies, if you remove that it should work again:

var myApp = angular.module("myApp", []);

Upvotes: 1

Related Questions