November 2019
Beginner
804 pages
20h 1m
English
A service in Angular is usually a class (by convention, with the Service suffix) that provides some reusable behavior, just like MediaService in our MediaMan application.
Services are marked as injectable using the @Injectable decorator. Angular can automatically instantiate services and inject them when and where needed; we'll discuss that in the next section.
Here's an example service:
import { Injectable } from '@angular/core';
@Injectable(
providedIn: 'root'
)
export class BookServiceImpl implements BookService {
...
}
Since components are user-facing, they are not supposed to worry too about much business logic and interaction with other parts of the application or other systems. Instead, components should focus on user experience ...
Read now
Unlock full access