Understanding the implementation

Let's break it down chunk by chunk. First, the declaration of the service is pretty standard:

import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import { Movie, MovieFields } from '../models/movie'; import { Observable } from 'rxjs/Rx'; import 'rxjs/Rx'; @Injectable() export class IMDBAPIService {  private moviesUrl:string = "app/marvel-cinematic-universe.json";  constructor(private http: Http) { }

Services are injectable. Consequently, we need to import and add the @Injectable annotation. We also import Http, Movie, MovieFields, Observable, and the operators of Rxjs. RxJS stands for reactive extensions for JavaScript. It is an API to perform observer, iterator, and functional ...

Get Angular Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.