AngularJS-$ timeout不是函数 [英] AngularJS - $timeout is not a function

查看:89
本文介绍了AngularJS-$ timeout不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在$ c0>函数中注入$ timeout,但是当我尝试调用它时,它得到的是not a function.为什么?

I try to inject $timeout in the run function but I get that it is not a function when I try to call it. Why ?

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

mainApp.run(['$rootScope', '$location', '$timeout'
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);

推荐答案

mainApp.run(['$rootScope', '$location', '$timeout'
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);

应该是:

mainApp.run(['$rootScope', '$location', '$route', 'authService', '$timeout',
        function ($rootScope, $location, $route, authService, $timeout) {
...
}]);

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

see 'The array annotation' part here:

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

这篇关于AngularJS-$ timeout不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆