In angular material form, I have a field with mat-option which contains list of options(i.e., a, b, c, d, e). When user selects/unselects one particular option(i.e., c), I need to do some manipulation. But I am getting undefined error, even if I select an option 'c' without selecting any other option.
I can understand that it is due to the index value[2] that I have used. I am not sure on how to identify if the user selects option 'C' or not Since it's index value may increase or decrease dynamically based on user selection.
Response array may look like:
value = {'d','c'} or value = {'c','b','a'} or value = {}
if(value[2] === 'c') {
console.log('c');
}
Can someone help me to write typescript code?