Advertisement
zorac

Untitled

Dec 11th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2.  
  3. import { Observable } from 'rxjs';
  4. import { HttpParams, HttpClient } from '@angular/common/http';
  5.  
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class PortalService {
  10. params: HttpParams;
  11.  
  12. constructor(private httpClient: HttpClient) {}
  13.  
  14. stockCountFilterRequest(queryParams): Observable<any[]> {
  15. this.params = new HttpParams();
  16. Object.keys(queryParams).forEach(key => {
  17. if (queryParams[key] !== '') {
  18. this.params = this.params.append(key, queryParams[key]);
  19. }
  20. });
  21.  
  22. return this.httpClient.get<any[]>('movements/stock', { params: this.params });
  23. }
  24. }
  25.  
  26.  
  27. stockCountFilterRequest() {
  28. // Fazer pedido para o filtro
  29. this.requestSubscription = this.portalService.stockCountFilterRequest(this.queryParams).subscribe(
  30. response => {
  31. console.log(response);
  32. },
  33. error => console.error('Error ' + error)
  34. );
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement