Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Observable } from 'rxjs';
- import { HttpParams, HttpClient } from '@angular/common/http';
- @Injectable({
- providedIn: 'root'
- })
- export class PortalService {
- params: HttpParams;
- constructor(private httpClient: HttpClient) {}
- stockCountFilterRequest(queryParams): Observable<any[]> {
- this.params = new HttpParams();
- Object.keys(queryParams).forEach(key => {
- if (queryParams[key] !== '') {
- this.params = this.params.append(key, queryParams[key]);
- }
- });
- return this.httpClient.get<any[]>('movements/stock', { params: this.params });
- }
- }
- stockCountFilterRequest() {
- // Fazer pedido para o filtro
- this.requestSubscription = this.portalService.stockCountFilterRequest(this.queryParams).subscribe(
- response => {
- console.log(response);
- },
- error => console.error('Error ' + error)
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement