Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, OnDestroy, Input, OnChanges } from '@angular/core';
- import { ActivatedRoute } from '@angular/router';
- import { Jsonp, URLSearchParams } from '@angular/http';
- import { PageService } from './service/page.service';
- import {PaginatePipe, PaginationControlsCmp, PaginationService} from 'ng2-pagination';
- @Component({
- selector: 'blog-app',
- templateUrl: 'app/blog.component.html',
- providers: [PageService, PaginationService],
- directives: [PaginationControlsCmp],
- pipes: [PaginatePipe]
- })
- export class BlogComponent implements OnInit, OnChanges {
- blogdata:any;
- @Input() offset: number = 0;
- @Input() limit: number = 1;
- @Input() size: number = 1;
- @Input() range: number = 3;
- currentPage: number;
- totalPages: number;
- constructor (private _pageService: PageService) {}
- ngOnInit(){
- this._pageService.getallblogs()
- .subscribe(data =>this.blogdata = data.data,
- error => console.log(error),
- () => console.log(this.blogdata));
- }
- ngOnChanges() {
- }
- getPages(offset: number, limit: number, size: number) {
- // TODO
- }
- getCurrentPage(offset: number, limit: number): number {
- return Math.floor(offset / limit) + 1;
- }
- getTotalPages(limit: number, size: number): number {
- return Math.ceil(Math.max(size, 1) / Math.max(limit, 1));
- }
- }
Add Comment
Please, Sign In to add comment