Working with RxJS & Angular

In this chapter, we will see how to use RxJs with Angular. We will not get into the installation process for Angular here, to know about Angular Installation refer this link −

We will directly work on an example, where will use Ajax from RxJS to load data.



import { Component } from '@angular/core';
import { environment } from './../environments/environment';
import { ajax } from 'rxjs/ajax';
import { map } from 'rxjs/operators'

   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css']
export class AppComponent {
   title = '';
   constructor() { = "";
      this.title = "Using RxJs with Angular";
      let a = this.getData();
   getData() {
      const response =
         .pipe(map(e => e.response));
      response.subscribe(res => {
         console.log(res); = res;


   <ul *ngFor="let i of data">
      <li>{{}}: {{}}</li>


We have used ajax from RxJS that will load data from this url −

When you compile the display is as shown below −

RxJs with Angular
Kickstart Your Career

Get certified by completing the course

Get Started