HttpService in Angular Framework

HttpService in Angular Framework:-

It is used to handle HttpRequest from external resources and fetch data from external resources .we will create web API or web services to get data from a remote server,web services, and web API will be called by HttpService in Angular Framework.

Web Services will be created by Server side script such as Java,PHP,.NET, PYTHON, Ruby, etc, and Consumed by Angular HTTP Service.

in Angular (currently on Angular-6) .subscribe() is a method on the Observable type. The Observable type is a utility that asynchronously or synchronously streams data to a variety of components or services that have subscribed to the observable.

import { Component, OnInit } from '@angular/core';
import { MyserviceService } from '../myservice.service';
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
export class HomeComponent implements OnInit {
  public persondata = [];
  constructor(private myser: MyserviceService) {

  ngOnInit() {
  this.myser.getData().subscribe((data) => {
         this.persondata = Array.from(Object.keys(data), k=>data[k]);


<h3>Users Data</h3>
   <li *ngFor="let item of persondata;">


Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)