Within my Angular component, I have a folder structure that needs to retain its previous state (which folder was open) even after reloading due to CRUD operations.
https://i.sstatic.net/z44k6.png
The API sends back a nested response utilized for generating the folder structure using *ngFor directive.
I attempted to save the previous state by relying on the '.highlight' class to identify the open folder, as shown below:
//highlight table selection & store the current folder selection
$('#Table').on('click', 'tbody tr', function(event) {
$(this).addClass('highlight').siblings().removeClass('highlight');
sessionStorage.setItem("previousFolder",$(this));
});
However, when trying to access the "previousFolder" from session storage and utilize typical jQuery methods like ".find()", ".parent()", or ".click()" in an Angular component, it is not feasible as it returns as HTMLelement Object.
What would be the most effective approach to save and restore jQuery results within an Angular component?