- AngularJS Web Application Development Cookbook
- Matt Frisbie
- 264字
- 2021-08-05 16:49:21
Introduction
In this chapter, you will learn how to effectively utilize AngularJS filters and services in your applications. Service types are essential tools required for code reuse, abstraction, and resource consumption in your application. Filters, however, are frequently glazed over in introductory courses as they are not considered integral to learning the framework basics. This is a pity as filters let you afford the ability to abstract and compartmentalize large chunks of application functionality cleanly.
All AngularJS filters perform the same class of operations on the data they are passed, but it is easier to think about filters in the context of a pseudo-dichotomy in which there are two kinds: data filters and search filters.
At a very high level, AngularJS data filters are merely tools that modulate JavaScript objects cleanly in the template. On the other half of the spectrum, search filters have the ability to select elements of an enumerable collection that match some of the criteria you have defined. They should be thought of as black box modifiers in your template—well-defined layers of indirection that keep your scopes free of messy data-parsing functions. They both enable your HTML code to be more declarative, and your code to be DRY.
Service types can be thought of as injectable singleton classes to be used throughout your application in order to house the utility functionality and maintain states. The AngularJS service types can appear as values, constants, factories, services, or providers.
Although filters and services are used very differently, a cunning developer can use them both as powerful tools for code abstraction.
- TypeScript入門與實(shí)戰(zhàn)
- Developing Middleware in Java EE 8
- Reactive Programming with Swift
- Unity Virtual Reality Projects
- Getting Started with CreateJS
- AngularJS深度剖析與最佳實(shí)踐
- Magento 2 Development Cookbook
- Mastering LibGDX Game Development
- JavaScript by Example
- Building a Quadcopter with Arduino
- Java:High-Performance Apps with Java 9
- JavaScript腳本特效編程給力起飛
- Go語言底層原理剖析
- Python大學(xué)實(shí)用教程
- Struts 2.x權(quán)威指南