Thursday, January 4, 2018

How to retrive data from json using angular2&4&5

Hey all,

Below is the component class for angular 2 and  get the data from JSON using like http service.


Create a component class

import { Component, OnInit } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'

@Component({
    moduleId: module.id,
    selector: 'my-app',
    templateUrl: 'app.component.html'
})

export class AppComponent implements OnInit {

pagedItems: any[];

this.http.get('./dummy-data.json')
            .map((response: Response) => response.json())
            .subscribe(data => {
                // set items to json response
                this.allItems = data;

            });
prevPage(){
            console.log( this.allItems);
   }

}

1 comment:

  1. Welcome To Brnfullstack: How To Retrive Data From Json Using Angular2 And 4 And 5 >>>>> Download Now

    >>>>> Download Full

    Welcome To Brnfullstack: How To Retrive Data From Json Using Angular2 And 4 And 5 >>>>> Download LINK

    >>>>> Download Now

    Welcome To Brnfullstack: How To Retrive Data From Json Using Angular2 And 4 And 5 >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete