import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { CartService } from '../../../services/cart.service'; import { SharedService } from '../../../shared/shared.service'; @Component({ selector: 'order-lookup', templateUrl: './order-lookup.component.html', styleUrls: ['./order-lookup.component.css'] }) export class OrderLookupComponent implements OnInit { orderLookup: any = {}; storeId: number; constructor(private cartService: CartService, private sharedService: SharedService, private router: Router) { } ngOnInit() { this.sharedService.storeId.subscribe((val: number) => { this.storeId = val; // getting the storeID }); } getOrderDetails(orderNumber: number) { this.sharedService.showSpinner(true); // spinner this.cartService.getCartSummary(this.storeId, orderNumber).subscribe(orderData => { this.sharedService.showSpinner(false); // spinner this.router.navigate(['/order-details'], { queryParams: { 'orderId': orderNumber, 'storeId': this.storeId } }); // Setting the params in the URL }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); }); } }