0

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>
5
  • It was working before, but now has suddenly stopped working and I get this error. - Undo you recent changes and find out what exact line causes the error. Commented Feb 12, 2016 at 12:03
  • I have tried all that, but can't seem to get it to work again, Commented Feb 12, 2016 at 12:03
  • 5
    why is there empty string in dependency injection array? Try removing that Commented Feb 12, 2016 at 12:04
  • Ahhh that was it. Thanks! Commented Feb 12, 2016 at 12:09
  • 1
    For future reference, you can replace your angular.min.js with angular.js which will give you a more detailed description of the error. Commented Feb 12, 2016 at 12:09

1 Answer 1

1
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", []);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.