web前端工程化之依赖注入

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/mayfla/article/details/78942562


传统依赖控制,由使用者自己new

 

依赖注入

控制器从内部转到了外部

注入器

 

 

service注入到product1中,在app模板中使用product1

service

Module

Product1

Product1.html

App.html

Product2

 

效果

service间进行注入

步骤:写组件-module提供-其他组件注入-调用

注入器的层级关系


angular4 服务依赖注入的三种方法

猜你喜欢

转载自blog.csdn.net/mayfla/article/details/78942562
今日推荐