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;
});
}
}
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[];
.map((response: Response) => response.json())
.subscribe(data => {
// set items to json response
this.allItems = data;
});
prevPage(){
console.log( this.allItems);}
}