Read Data from JSON File in AngularJS 2

Last Reply 6 months ago By dharmendr

Posted 6 months ago


i am not able To get The data From the json file,

below is My code.


import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import 'rxjs/add/operator/map';


export class EmployeeService {
  private  url: string = './jsf/example_1.json';

  constructor(private _http: Http) {


   getallemployee() {

     return this._http.get(this.url)
       .map((response: Response ) => response.json());



import {Component, OnInit} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {AppComponent} from '../app.component';
import {EmployeeService} from './employee.service';

  selector : 'app-root1',
  templateUrl : './employee.component.html',

export class EmployeeComponent implements OnInit {

  Employee: string [];

  constructor(private _empservice: EmployeeService) {
  ngOnInit() {
          .subscribe(resEmpDate => this.Employee = resEmpDate);
        console.log( this._empservice.getallemployee()
          .subscribe(resEmpDate => this.Employee = resEmpDate));



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">

    table, th, td {
        border: 1px solid #969696;


<div class="row">
  <div class="col-lg-12">
    <table *ngIf="Employee">
      <!-- ADD HEADERS -->
      <!-- BIND ARRAY TO TABLE -->
      <tr *ngFor="let bird of Employee">

and Explain me how To put break point, in that so i can check

thanks and regards 'siddu