Currently, I am developing an Angular application that involves handling an array structured like the one below.
[
{
Code: "123",
Details:[
{
Id: "1",
Name: "Gary"
},
{
Id: "2",
Name: "Rocky"
}]
},
{
Code: "456",
Details:[
{
Id: "3",
Name: "Cindy"
},
{
Id: "4",
Name: "Jacky"
}]
}
]
This array can have multiple elements, each containing a unique Code value and an array of Details (which can vary in length). The Details array consists of Id and Name pairs. In my scenario, I receive an Id from query parameters and need to cross-reference it within the Details arrays to retrieve the corresponding Code value. For instance, if the Id from the query parameter is 4, then I should return the Code value 456. Similarly, for an Id value of 2, I should fetch the Code value 123. How can this be achieved effectively?