- 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.
- Unity 2020 By Example
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- Python快樂編程:人工智能深度學習基礎
- Android和PHP開發最佳實踐(第2版)
- 軟件測試項目實戰之性能測試篇
- Python Tools for Visual Studio
- 用Flutter極速構建原生應用
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- Unity 5.x By Example
- 量化金融R語言高級教程
- MATLAB for Machine Learning
- 微信小程序全棧開發技術與實戰(微課版)
- Python圖形化編程(微課版)
- Processing創意編程指南
- .NET 4.5 Parallel Extensions Cookbook