AngularJs--Dependency Injection 规则
参考:https://docs.angularjs.org/guide/di
AngularJs的依赖注入简称DI,在AngularJs项目中可以无处不在,到底应该注入些什么东东呢?一直是迷迷糊糊的,为此今天特意看了官方文档,终于弄明白了,至少更理解一些了 :)

【译】
- Services, directives, fillters 和 animations 由工厂方法或构造函数定义,并且可以使用“services”,“values”和“constants”作为依赖注入
- Controllers 由构造函数定义,它可以作为依赖关系注入任何“service”和“value”中,但也可以提供“特殊依赖关系”。
- run 方法接受一个函数,该函数可以用“services”,“values”和“constants”作为依赖注入。请注意,您不能将“providers”插入 run 块中。
- config方法接受一个函数,可以使用“providers”和“constants”作为依赖注入。请注意,您不能在 config 中注入“service”和“value”。
- provider只能与其他“provider”一起注入。但是,只有预先注册的provider才可以注入。这与services不同,services注册与顺序无关。
在这里还涉及到一个 value 和 constant 的区别,详细内容请参考:https://stackoverflow.com/questions/30327651/angularjs-constants-vs-values
AngularJs--Dependency Injection 规则的更多相关文章
- AngularJs学习笔记--Dependency Injection(DI,依赖注入)
原版地址:http://code.angularjs.org/1.0.2/docs/guide/di 一.Dependency Injection(依赖注入) 依赖注入(DI)是一个软件设计模式,处理 ...
- [转载][翻译] IoC 容器和 Dependency Injection 模式
原文地址:Inversion of Control Containers and the Dependency Injection pattern 中文翻译版本是网上的PDF文档,发布在这里仅为方便查 ...
- Ninject学习(一) - Dependency Injection By Hand
大体上是把官网上的翻译下而已. http://www.ninject.90iogjkdcrorg/wiki.html Dependency Injection By Hand So what's Ni ...
- MVC Controller Dependency Injection for Beginners【翻译】
在codeproject看到一篇文章,群里的一个朋友要帮忙我翻译一下顺便贴出来,这篇文章适合新手,也算是对MEF的一个简单用法的介绍. Introduction In a simple stateme ...
- 控制反转Inversion of Control (IoC) 与 依赖注入Dependency Injection (DI)
控制反转和依赖注入 控制反转和依赖注入是两个密不可分的方法用来分离你应用程序中的依赖性.控制反转Inversion of Control (IoC) 意味着一个对象不会新创建一个对象并依赖着它来完成工 ...
- Dependency Injection
Inversion of Control - Dependency Injection - Dependency Lookup loose coupling/maintainability/ late ...
- Inversion of Control Containers and the Dependency Injection pattern(转)
In the Java community there's been a rush of lightweight containers that help to assemble components ...
- Scala 深入浅出实战经典 第57讲:Scala中Dependency Injection实战详解
王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-87讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...
- 【译】Dependency Injection with Autofac
先说下为什么翻译这篇文章,既定的方向是架构,然后为了学习架构就去学习一些架构模式.设计思想. 突然有一天发现依赖注入这种技能.为了使得架构可测试.易维护.可扩展,需要架构设计为松耦合类型,简单的说也就 ...
- 依赖注入 | Dependency Injection
原文链接: Angular Dependency Injection翻译人员: 铁锚翻译时间: 2014年02月10日说明: 译者认为,本文中所有名词性的"依赖" 都可以理解为 & ...
随机推荐
- 【总结整理】关于GrowingIO、友盟、google analysis等数据分析
作者:纯银V链接:https://www.jianshu.com/p/394ec6c96c98來源:简书简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处. 埋点主要分为四步:第一步是 ...
- 4-fiddler抓包中文乱码:
接受到的html被压缩了,要解压,在工具栏有decode
- jquery表单数据反序列化为字典
.前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1 ...
- Python基础-3
目录 1. 函数基本语法及特性 2. 参数与局部变量 3. 返回值 知识插入:嵌套函数 4.递归 5.匿名函数 6.函数式编程介绍 7.高阶函数 8.内置函数 一.函数基本语法 函数是什么? 函数一词 ...
- [GO]随机生成四们数字
package main import ( "math/rand" "time" "fmt" ) func InitData(p *int) ...
- DataAnnotationsModelValidator-基于数据注解方式的model验证器
http://www.cnblogs.com/artech/archive/2012/04/10/how-mvc-works.html http://www.cnblogs.com/artech/ar ...
- 【C#】is 和 as
看个例子: public class User { } public class Group { } class Program { static void Main(string[] args) { ...
- C#常见编译报错
mCaster.PlayAnim(ANIMID.ASTD); No overload for method 'PlayAnim' takes '1' arguments PlayAnim()内有两个参 ...
- 【SQL】- 基础知识梳理(一) - 数据库
一.引言 知识分享这个事情在公司会议上被提出过几次,可一直因各种事情耽搁下来,“我不如地狱,谁入地狱”,怀着这样一种心态,写下了 数据库系列知识分享. 本文将一步步通过循序渐进的方式带你去了解数据库. ...
- angular 重定向路由
const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', compo ...