On the page labeled standing-orders-details
, I have configured it so that the display of the New Order
button is hidden, but only if I first visit the new-order
page.
- To begin, I need to ensure that the
New Order
button remains hidden on thestanding-orders-details
page.
In my TypeScript file, I declared a variable like this:
isNewOrderVisited: boolean = false;
Next, here's the method implementation:
goToNewOrder(): void {
this.isNewOrderVisited = true;
this.router.navigate(['/orders/newOrder']);
}
The HTML template contains the button code as follows:
<button *ngIf="isNewOrderVisited" (click)="goToNewOrder()" class="btn btn-primary m-1" type="button">New Order</button>
Now, as expected, when I am on the standing-orders-details
page, the New Order
button stays hidden!
- However, there is an issue! After creating an order from the
new-order
page, upon redirection to thestanding-orders-details
page, I should now see theNew Order
button!
I'm unsure how to tackle this challenge?
I believe the problem lies within this portion of the code:
newOrderRequest(tokens: SignatureOtpModel | undefined): void {
if (tokens) {
this.service.createNewOrder(this.order!, tokens).pipe(
takeUntil(this.unsubscribe$)
).subscribe(res => {
if (res.RETURNCODE === ApiResponseCodeEnum.Ok) {
this.router.navigate(['/orders/standingOrdersDetails']);
} else {
this.router.navigate(['/orders/error/' + ConfirmOrderTypeEnum.Add + '/' + JSON.stringify(res.RETURNLIST)]);
}
});
}
}
I've shared all my code with you for context.
standing-orders-details.component.ts
// Code snippet for StandingOrdersDetailsComponent
// Includes declarations and methods for handling standing orders
new-order.component.ts
// Code snippet for NewOrderComponent
// Contains functionalities related to new order creation and details fetching