how to inject dependency into module.config(configFn) in angular

后端 未结 8 1165
轮回少年
轮回少年 2020-11-27 14:40

In Angular, we can inject $routeProvider to the config function

module.config(function ($routeProvider) {


});

I

8条回答
  •  盖世英雄少女心
    2020-11-27 15:07

    If it can make things easier for some of you.

    Per explained in this answer, you can just append Provider to your custom service and then access the internal functions using $get().

    It may not be the cleanest solution, but it does the job.

    module.config(function ($routeProvider, myServiceProvider) {
     // Call a function hello() on myService.
     myServiceProvider.$get().hello();
    });
    

提交回复
热议问题