Last active
December 18, 2021 11:14
-
-
Save NazemMahmud/fbdda84ee4087b4102066ff3bad8bf46 to your computer and use it in GitHub Desktop.
Angular Material: main service ts file for pagination sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {HttpClient, HttpParams} from '@angular/common/http'; | |
@Injectable() | |
export class MainService { | |
constructor(protected http: HttpClient) {} | |
private readonly baseUrl = "127.0.0.1:8000/api"; // here use your project's base url | |
private additionalUrl = "/employees"; // here use your remaining route url | |
protected _url = `${this.baseUrl}${this.additionalUrl}`; | |
getAll(pageOffset: any, page, orderBy?): Observable<any> { | |
const params = new HttpParams({ | |
fromObject: {pageOffset, page, orderBy} | |
}); | |
return this.http.get(`${this._url}`, {params: params ? params : null}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment