Currently, I am in the midst of developing an AngularJS application integrated with a C# Web API.
I have two controllers: A and B.
In controller A, there is a list of objects. When I click "Add" (in between two list items), I am redirected to controller B.
//add item
$location.path("/controllerB")
Within controller B, I encounter yet another list of objects. Upon selection, the chosen item should then populate Controller A's list at a specified index.
My current approach involves using LocalStorage. By storing the selected object in localStorage for access within Controller A, I face the challenge of needing the index as well. If I also store the index in LocalStorage for access in Controller B, it seems like a questionable decision.
At this point, here's what I'm thinking:
1. Save the index from Controller A in local storage before navigating to B.
2. Save the selectedItem from Controller B in local storage before returning to A.
3. Push the selectedItem to the specified index.
Please provide guidance on the AngularJS approach to tackle this issue effectively.