I'm currently working on an AngularJS application that is designed to generate multiple choice quizzes. The questions and corresponding choices are managed within the following model.
$scope.testFormChoiceCount = [
{question: '', choices: [
{choice: ''},
{choice: ''},
{choice: ''}
]
},
{question: '', choices: [
{choice: ''},
{choice: ''},
{choice: ''}
]
},
];
The issue I am facing: When I add a question, a new object is added to the model array. However, if I delete a question (such as the first one), the model binding breaks down, causing an error when trying to input data into the remaining questions.
Could it be that my ng-model binding is incorrect? Any assistance in solving this problem would be greatly appreciated.
Take a look at the Fiddle here: http://jsfiddle.net/D7M2Z/
This is how I remove an object from the model array:
$scope.removeQuestion = function(index){
$scope.testFormChoiceCount.splice(index, 1);
}