- Switching to Angular(Third Edition)
- Minko Gechev
- 213字
- 2021-07-02 15:23:30
Dependency injection
Maybe the first framework on the market that included Inversion of Control (IoC) through Dependency Injection (DI) in the JavaScript world was AngularJS. DI provides a number of benefits, such as easier testability, better code organization and modularization, and simplicity. Although the DI in AngularJS does an amazing job, Angular took this even further. Since Angular is on top of the latest web standards, it uses the syntax of ECMAScript 2016 decorators for annotating the code for using DI. Decorators are quite similar to the decorators in Python or annotations in Java. They allow us to decorate the behavior of a given object, or add metadata to it, using reflection. Since decorators are not yet standardized and supported by major browsers, their usage requires an intermediate transpilation step.
The new DI is much more flexible and feature-rich. It also fixes some of the pitfalls of AngularJS, such as the different APIs; in the first version of the framework, some objects are injected by position (such as the scope, element, attributes, and controller in the link function of the directives) and others, by name (using parameters names in controllers, directives, services, and filters).
We will take a further look at the Angular's dependency injection API in Chapter 6, Dependency Injection in Angular.
- 多媒體CAI課件設(shè)計與制作導論(第二版)
- DB2 V9權(quán)威指南
- 機器學習系統(tǒng):設(shè)計和實現(xiàn)
- R語言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- Offer來了:Java面試核心知識點精講(原理篇)
- 華為HMS生態(tài)與應(yīng)用開發(fā)實戰(zhàn)
- Java編程指南:基礎(chǔ)知識、類庫應(yīng)用及案例設(shè)計
- Effective Python Penetration Testing
- TypeScript實戰(zhàn)指南
- Python數(shù)據(jù)可視化之Matplotlib與Pyecharts實戰(zhàn)
- 批調(diào)度與網(wǎng)絡(luò)問題的組合算法
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- Mastering Git
- Mastering Akka
- 用案例學Java Web整合開發(fā)