官术网_书友最值得收藏!

Services

Services are user-defined classes used to solve problems. Angular recommends only having template-specific codes in components. A component's responsibility is to enrich the UI/UX in the Angular application and delegate business logic to services. Components are consumers of services:

Application-specific or business logic such as persisting application data, logging errors, and file storage should be delegated to services, and components should consume the respective services to deal with the appropriate business or application-specific logic:

For example, we can have a service called BookService that deals with inserting new books, editing or deleting existing books, and fetching a list of all the books available.

We will see more about services in Chapter 11, Implementing Angular Pipes.

主站蜘蛛池模板: 天水市| 河源市| 牙克石市| 兴化市| 兰坪| 桃源县| 来安县| 宁安市| 民丰县| 南陵县| 工布江达县| 赤城县| 犍为县| 南雄市| 尉犁县| 巨鹿县| 辽阳市| 浙江省| 诏安县| 华容县| 茂名市| 长沙市| 姜堰市| 定结县| 马龙县| 牟定县| 辽宁省| 双鸭山市| 禹州市| 中江县| 德阳市| 龙南县| 老河口市| 丹阳市| 独山县| 江安县| 耒阳市| 静宁县| 石门县| 阿克陶县| 东莞市|