Can $q and $http be injected in the .config section

前端 未结 3 639
余生分开走
余生分开走 2020-12-18 20:58

Is it possible to inject $q in the config section of my module? Below is my sample config section.

.config([\'$q\', function ($q) {
    var func = function (         


        
3条回答
  •  误落风尘
    2020-12-18 21:21

    You can use angular.injectorto load $http and $q, and probably other services in your config block:

    angular.module('myApp').config(function () {
        var injector = angular.injector(['ng']),
            http = injector.get('$http'),
            q = injector.get('$q');
    });
    

提交回复
热议问题