0

I have controller and inside a $timeout function:

.controller('MapCtrl', ['$scope', '$http', '$log', '$timeout', function ($scope, $http, $interval, $log, $timeout) {
   $timeout(function () {
                $scope.marker.coords = {
                    latitude: 42.1451,
                    longitude: -100.6680
                };
                $scope.dynamicMoveCtr++;
                $timeout(function () {
                    $scope.marker.coords = {
                        latitude: 43.1451,
                        longitude: -102.6680
                    };
                    $scope.dynamicMoveCtr++;
                }, 2000);
            }, 1000);
}]);

Why it gives me error:

typeError: $timeout is not a function at new (angularmy.js:2879) at Object.e [as invoke] (angular.min.js:36) at $get.x.instance (angular.min.js:75)

At another controller function $timeout works correct

1
  • try to order the dependencies correctly. Commented May 19, 2015 at 10:00

2 Answers 2

1
.controller('MapCtrl', ['$scope', '$http', '$log', '$timeout', function ($scope, $http, $interval, $log, $timeout)

The string arguments don't match the arguments being passed to the function.

'$scope', '$http', '$log', '$timeout'

($scope, $http, $interval, $log, $timeout)
Sign up to request clarification or add additional context in comments.

Comments

1

You forgot to inject the $timeout parameter.

Fix it like this:

.controller('MapCtrl', ['$scope', '$http','$interval', '$log', '$timeout', function ($scope, $http, $interval, $log, $timeout) {

2 Comments

It is the $interval params but you are right for the fix
its work by place in array, the last param in function($timeout) got undefined

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.