DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on • Edited on

Query Param Queryparam

 <button routerLink="/pre-launch-form" [queryParams]="{ offerId: offerData?.id }" class="button">Click Me</button>              

Enter fullscreen mode Exit fullscreen mode
this.router.navigate(['my-order'],{queryParams:{orderId: res.data._id}});              

Enter fullscreen mode Exit fullscreen mode
export class MyOrderComponent implements OnInit {
  // Store Data
  orderId: any;
  orderDetails: any;

  // Subscription
  private subRouteOne: Subscription;
  private subGetData1: Subscription;

  private readonly activatedRoute = inject(ActivatedRoute);
  private readonly productOrderService = inject(ProductOrderService);

  ngOnInit(): void {
    this.subRouteOne = this.activatedRoute.queryParamMap.subscribe((qParam) => {
      this.orderId = qParam.get('orderId');
      if (this.orderId) {
        this.getOrderById(this.orderId);
      }
    });
  }

  private getOrderById(id: string) {
    console.log('get id', id);
    // const select = 'courseModules';
    this.subGetData1 = this.productOrderService.getOrderById(id).subscribe({
      next: (res) => {
        if (res.success) {
          this.orderDetails = res.data;
          console.log('order details', this.orderDetails);
        }
      },
      error: (err) => {
        console.log(err);
      },
    });
  }

  /**
   * ON Destroy
   */
  ngOnDestroy(): void {
    if (this.subRouteOne) {
      this.subRouteOne.unsubscribe();
    }
    if (this.subGetData1) {
      this.subGetData1.unsubscribe();
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay