February 2019
Beginner
694 pages
18h 4m
English
In order to interact with our newly created REST endpoints, we will follow the Single Responsibility design paradigm, and create an Angular service. This service will be marked with the @Injectable decorator, which allows us to use Angular's DI framework to inject an instance of this service when and where it is needed. Let's create a new file in the /app/services directory named board.service.ts as follows:
import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { Observable } from "rxjs"; @Injectable({ providedIn: 'root' }) export class BoardService { constructor(private httpClient: HttpClient) { } getManufacturerList(): Observable<Object> { return this.httpClient.get('/api/manufacturers'); ...Read now
Unlock full access