I have a resolver set up to retrieve all model data from my database that matches a specific ID. When I request all model data where the detailId is 140, it returns an array containing all items with that detailId.
For example:
0: {detailId: 140, area: 4, depth: 1, complete: false}
1: {detailId: 140, area: 5, depth: 4, complete: false}
2: {detailId: 140, area: 6, depth: 8, complete: false}
3: {detailId: 140, area: 7, depth: 10, complete: false}
4: {detailId: 140, area: 8, depth: 3, complete: false}
5: {detailId: 140, area: 9, depth: 3, complete: false}
My goal is to retrieve the depth value for each specific area so that I can dynamically assign the value using formBuilder based on the index (e.g., area: 4 corresponds to index4 and so on):
(I'm considering passing the index/area value to a function where the calculation takes place.)
this.detailForm = new FormBuilder().group({
index4: [this.getDepth(4)],
index5: [this.getDepth(5)],
index6: [this.getDepth(6)]
});
I would need a function similar to this to get the depth value based on the area:
getDepth(index: number) {
// Retrieve and return depth value where area matches the index
}
Any suggestions on how to achieve this functionality?