I want to add dynamic formarray based on api response.Below are the condition for pushing the form
In Below response, It will check for key otherDetails, and if otherDetails array key is present,
check the length of otherDetails array, and check for processTechType.
For ex – In below response, Length of First otherDetails array is 2 becuase First otherDetails array contain 2 objects, and it contain processTechType Continuous and Batch, So it will call addContinuous for processTechType Continuous and addBatch push function for processTechType Batch .
For ex – In Below response, Length of second otherDetails array contain 1 objects, and it contain processTechType Batch, So it will call addBatch push function likewise.
Can anyone please help me prepare this logic based on response.
I am getting below response array of object from API.
const myObj = [
{
'makeLineName': 'Test1',
'otherDetails': [
{
'processTechType': 'Continuous'
},
{
'processTechType': 'Batch',
}
]
},
{
'makeLineName': 'Test2',
'otherDetails': [
{
'processTechType': 'Batch'
}
]
}
];
Below is my code
addContinuous() {
this.continuousType().push(this.createContinuousForm());
}
addBatch() {
this.batchType().push(this.createBatchForm());
}
getData() {
this.makeLineData = resp; // Here i am getting the object.
console.log(this.makeLineData, "this.makeLineData");
}