Question:
private _secretQuestions: {question: number, answer: string}[];
Within my HTML, I have three select boxes representing questions, each with a corresponding input box for answers. My goal is to map the selected questions and input values to the _secretQuestions property. To account for the limited number of questions (three), I initialized the array as follows:
private _secretQuestions = [{question: 0, answer: ""}, {question: 0, answer: ""}, {question: 0, answer: ""}];
However, I am struggling to write the setter for this property:
set secretQuestions(value: Array<{question: number, answer: string}>) {
// what code here?
}
When binding in my HTML,
<select class="form-control" [(ngModel)]="regModel.secretQuestions">
... </select>
triggers the setter, but if I could somehow trigger the setter like:
<select class="form-control" [(ngModel)]="regModel.secretQuestions[0].question">
I believe it would help resolve my issue.
Any suggestions on the correct approach to take?
EDIT
The _securityQuestions property is part of a Provider which is injected into the component. It is essential for the property to be private within the provider.