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

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.

主站蜘蛛池模板: 洪湖市| 宣汉县| 林州市| 遂宁市| 新民市| 绥中县| 洪洞县| 庄浪县| 罗定市| 阳曲县| 哈密市| 凤山县| 遵化市| 浮梁县| 乌鲁木齐县| 梨树县| 黄大仙区| 平顶山市| 清水河县| 清远市| 卢龙县| 射阳县| 新龙县| 奎屯市| 林甸县| 潮州市| 红河县| 乡城县| 沙雅县| 鄂温| 松桃| 福海县| 城固县| 水城县| 卓尼县| 鹤庆县| 光山县| 衡阳市| 平邑县| 新密市| 康平县|