My model looks like this:
export class SelectedApplicationFeatures {
id: number;
}
In my TypeScript file, I imported the model as shown below:
import { SelectedApplicationFeatures } from "src/app/models/selectedApplicationFeatures.model";
selectedApplicationFeatures: SelectedApplicationFeatures[]=[];
When I tried to set values in selectedApplicationFeatures within a function, I encountered an issue. Here is the code snippet:
for (let i = 0; i < _applicationFeatures.length; i++) {
if (_applicationFeatures[i].featureChecked == true) {
let j = 0;
this.selectedApplicationFeatures[j].id = _applicationFeatures[i].id;
j++;
}
}
The error message I received was:
"ERROR TypeError: Cannot read properties of undefined (reading '0')".
//_applicationFeatures: