的服务,工厂和放大器执行顺序;在AngularJS供应商? [英] Execution order of services, factories & providers in AngularJS?

查看:118
本文介绍了的服务,工厂和放大器执行顺序;在AngularJS供应商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问在predefined为了AngularJS框架执行所有上面提到或者是这个由程序员完成?

Does AngularJS framework executes all mentioned above in a predefined order or is this done by the programmer?

推荐答案

在用语方面,工厂可以生成服务,和提供给请求它们的组件提供服务。如果某些服务依赖于其他服务,那么就应该肯定会有一些另类服务和供应商的执行。确保所有这些事情发生在正确的顺序,以允许实例化所有的服务是角的依赖注入的工作。

In terms of terminology, factories can generate services, and providers provide services to components that request them. If some of your services depend on other service, then there should certainly be some alternative executing of services and providers. Making sure that all of these things happen in the right order to allow all the services to be instantiated is the job of Angular's dependency injection.

一个问题要问的是,为什么你关心什么顺序运行工厂的功能呢?如果你正确地声明你的依赖和你的服务是适当取消耦合,角应该照顾你的东西。你可能会遇到的唯一特殊的案例是一个圆形的依赖,你可以看到的这里

One question to ask is, why do you care what order the factory functions run in? If you declare your dependencies correctly and your services are appropriately un-coupled, Angular should take care of things for you. The only exotic case you might run into is a circular dependency, which you can see some discussion of here.

这篇关于的服务,工厂和放大器执行顺序;在AngularJS供应商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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