I'm using Angular 6 and have function which will change the value of a property and also adds the property to an array if the array exists.
When property value is true
{
"myArray": ["property1"],
"properties": {
"property1": {
"value": true
},
"property2": {
"value": false
}
}
}
But when I'm trying to change the value of the property if there is no array present then I get array is undefined error
{
"properties": {
"property1": {
"value": false
},
"property2": {
"value": false
}
}
}
How can I add back an array and execute the same method which I'm doing when there is an array existing
like
{
"myArray": ["property2"],
"properties": {
"property1": {
"value": false
},
"property2": {
"value": true
}
}
}