import { InternalPageService } from './../../shared/internal-page.service'; import { AuthServiceService } from './../../shared/auth-service.service'; import { Component, OnInit } from '@angular/core'; import { NgxSpinnerService } from 'ngx-spinner'; @Component({ selector: 'app-circulars-page', templateUrl: './circulars-page.component.html', styleUrls: ['./circulars-page.component.css'] }) export class CircularsPageComponent implements OnInit { constructor(private authSer: AuthServiceService, private spinner: NgxSpinnerService, private internalService: InternalPageService) { } count: number; perPagePagenation: number = 10; dataTableNumber:number = 5; data = []; //p: number[] = []; currentPage:number = 1; typeCircu:number = 0; ngOnInit() { this.spinner.show(); this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, 0).subscribe( (responce) => { console.log(responce); this.data = responce['tabs']; this.count = responce['count']; this.perPagePagenation = responce['per_page']; this.spinner.hide(); }, (error) => { console.log(error); } ) }; // /change page onPageChange(pagenationNumber) { this.spinner.show(); this.currentPage = pagenationNumber; this.data = []; //console.log(pagenationNumber); //console.log(this.pageId); this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, this.typeCircu).subscribe( (responce) => { console.log(responce); this.data = responce['tabs']; this.count = responce['count']; this.perPagePagenation = responce['per_page']; //console.log(this.tabsList); this.spinner.hide(); }, (error) => { console.log(error); this.spinner.hide(); } ); }; onGetData(id) { this.spinner.show(); this.typeCircu = id; this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, id).subscribe( (responce) => { console.log(responce); this.data = responce['tabs']; this.count = responce['count']; this.perPagePagenation = responce['per_page']; this.spinner.hide(); }, (error) => { console.log(error); this.spinner.hide(); } ); } //determine the list count from select element onGetValue(event) { this.spinner.show(); this.data = []; this.dataTableNumber = event.target.value; this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, this.typeCircu).subscribe( (responce) => { console.log(responce); this.data = responce['tabs']; this.count = responce['count']; this.perPagePagenation = responce['per_page']; this.spinner.hide(); }, (error) => { console.log(error); this.spinner.hide(); } ); } }