Providers、Controller 、Service、DirectiveFactory

Providers

是唯一一种你可以传进 .config() 函数的 service。当你想要在 service 对象启用之前,先进行模块范围的配置,那就应该用 provider

Controller

创建控制器

Directive

创建指令

Service

所有的services都是singleton(单例)

Service 是用"new"关键字实例化的。因此,你应该给"this"添加属性,然后 service 返回"this"。你把 service 传进 controller 之后,在controller里 "this" 上的属性就可以通过 service 来使用了

Factory

 

本文来自博客园,作者:广林,转载请注明原文链接:https://www.cnblogs.com/guanglin/p/5200126.html

原文地址:https://www.cnblogs.com/guanglin/p/5200126.html