AngularJS - $ timeout不是一个函数

Ton*_*ony 5 angularjs

我尝试在run函数中注入$ timeout,但我知道它是not a function在我尝试调用它时.为什么?

var mainApp = angular.module('mainApp', ['ngRoute', 'ngAnimate', 'ui.bootstrap', ngCookies']);

mainApp.run(['$rootScope', '$location', '$timeout'
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);
Run Code Online (Sandbox Code Playgroud)

Ras*_*lom 16

mainApp.run(['$rootScope', '$location', '$timeout'
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);
Run Code Online (Sandbox Code Playgroud)

应该:

mainApp.run(['$rootScope', '$location', '$route', 'authService', '$timeout',
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);
Run Code Online (Sandbox Code Playgroud)

请参阅此处的"数组注释"部分:

https://docs.angularjs.org/api/auto/service/$injector