ANGULAR - Creating Specific Query Parameters When Navigating Backwards

Is there a way to automatically include query parameters when navigating back to the previous page using the browser's default back button?

For instance, when calling a customer-hierarchy component view, you can add query parameters like this:

<a [routerLink]="['/customer-hierarchy']" [queryParams]="{filterBy: currentActiveFilter}">Details</a>

But how can we achieve the same result for the previous page triggered by clicking the default back button in the browser?

Answer №1

The solution to this issue was implementing session storage. Whenever a filter update is made on the table, I save these filters in session storage using the following code snippet:

sessionStorage.setItem('workordersTableFilters', JSON.stringify(this.currentActiveFilter));

To retrieve data from session storage:

const workordersTableFilters = sessionStorage.getItem('workordersTableFilters');
if (workordersTableFilters != null) {
   //Proceed with using the loaded data
}

Note: No external libraries or imports are needed for this implementation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Publish the file on Angular 7 route for accessibility

I'm currently stuck on an issue that I can't seem to figure out. I'm attempting to link my website to Apple Pay through Stripe's PaymentRequest feature. However, I'm running into difficulties with one of the requirements they have ...

Navigating a page without embedding the URL in react-router-dom

In my application, I am utilizing react-router-dom v5 for routing purposes. Occasionally, I come across routes similar to the following: checkup/step-1/:id checkup/step-2/:id checkup/step-3/:id For instance, when I find myself at checkup/step-1/:id, I int ...

The NextAuth getServerSession function is functional when used with a POST API method, but it

Encountering an issue where getServerSession functions correctly on a POST route but not on a GET route. import { getServerSession } from "next-auth" import { authOptions } from "../../auth/[...nextauth]/route" import { NextResponse } f ...

When the keyboard appears, the Ionic 2 form smoothly slides upwards

I am currently working with the most recent version of Ionic 2. In my code, I have a <ion-content padding><form></form></ion-content> containing a text input. However, when attempting to enter text on an Android device, the keyboard ...

Is there a way to define the length of children when performing props type checking?

I need my component to only allow for three children that are considered as type React.ReactChild. However, I'm uncertain if ReactChild is the most suitable type to validate. Essentially, these children should be three distinct sections. function Top ...

Currency formatting in ionic2 is not working properly when tested on a

Formatting currency in Ionic2 framework can be done like this: {{finalPremium | currency : 'eur' : true :'.2-2' }}. Interestingly, this functionality only appears to function properly in the browser. When tested on an iPhone device, no ...

How can I specify the parameter type as "any object value" in TypeScript?

What is the proper way to annotate a parameter type as "any value of an object"? class ExampleClass { private static readonly MODES = { DEVELOPMENT: 0, PRODUCTION: 1, TEST: 2 } // Any Value of ExampleClass.MODES c ...

Error encountered: Unable to locate React Node during FaC testing with Jest and Enzyme

In my React Native app, we recently integrated TypeScript and I'm in charge of migrating the unit tests. One particular test is failing unexpectedly. The app includes a <LoginForm /> component that utilizes Formik. //... imports export inte ...

Trigger a change event for a Material Checkbox by referencing its unique identifier

<div *ngFor="let cus of deselectedList | keyvalue" (click)="clickCheckBox('customer_'+cus.key+'_checkbox')"> {{cus.key}} <mat-checkbox id="customer_{{cus.key}}_checkbox" (change ...

Issue with Angular: Service and ngrx returning unexpected undefined values

Currently, I am diving into Angular, focusing on topics like DI, Services, and Ngrx, but I've hit a roadblock that's puzzling me. Interestingly, when I check the values of this.getBase() and this.baseRateSaving in the console, they show up just ...

Can we determine the type signature of useCallback for an event handler by inference?

Currently, I am working with TypeScript and React to implement a callback function using an arrow function on a Material UI <Select> component: import React from 'react'; import MenuItem from '@material-ui/core/MenuItem'; import ...

Acquiring the URL from the ajax response with EmberJS

Seeking assistance on extracting the URL from an Ajax response within Ember. This is necessary for handling a particular scenario where the server redirects to a different URL and provides data from the new URL (302 redirect). By capturing the URL from th ...

Looping through GET requests

I have a Next.js and TypeScript application where a request is made to a webhook integration that returns a Google sheet in JSON format. I've noticed that the integration keeps getting called repeatedly in a loop. Here is a snippet of my code: import ...

Excluding a Navbar in Angular 2: What is the best way to hide the navbar on a

Within app.component.html, I always incorporate the navbar on every page with the following code: <app-navbar></app-navbar> Is there a way to omit the navbar from a specific page? ...

Working with Arrays of Objects in Typescript with Angular

I am currently trying to define an array of objects in my Typescript code. However, I am encountering issues when accessing these objects. Below is the snippet of my code along with a screenshot showing the output of this.attachments. info: Info[]; if (t ...

Pass information from a child component to a parent component within a React.js application

Using the Semantic-UI CSS Framework, I have implemented a dropdown menu and want to be able to select an item from it and identify which item has been selected. While I can determine the selected item within the child component and set its state, I am faci ...

Angular Dependency Injection: Individual instances of each service are provided for every module usage

Within my application, there is a module called "FileUpload". The upload service included is "UploadService", which receives a service injection with the interface "RequestService." I also have two other modules: FileManager1 and FileManager2. Each file m ...

Is there a method to modify the cell and date color with a click action in fullcalendar using Angular?

I am looking for a way to change the color of a cell and its corresponding date simultaneously when clicking on it in the fullcalendar. So far, I have been able to change the cell background color using .fc-highlight in the style.css file. However, I am ...

A guide on transforming a string into an array of objects using Node.js

Hey everyone, I have a single string that I need to convert into an array of objects in Node.js. let result = ""[{'path': '/home/media/fileyear.jpg', 'vectors': [0.1234, 0.457, 0.234]}, {'path': '/home/med ...

Retrieving targeted information from the store following the retrieval of data from an API

In my project, I have set up an RXJS effect that loads an organization from the server upon a certain action. Once the organization is loaded, I attempt to select a bookmark from the NGRX store based on the organization ID. Finally, I dispatch a success ac ...