I am trying to add the delete function for the option list: But always getting the error message: indexOf is undefined!
Could someone help me on that? Thanks in advance!
Here is part of my code:
Html:
<div class="question_typeList" ng-switch-default>
<table class="question_heading">
<tbody>
<tr ng-repeat="option in question.options">
<td>
<input class="question_textfield" placeholder="My Option" ng-model="option.value[lang]">
<button ng-click="removeOption(option)">X</button>
</td>
<td>
{{option.value}}
</td>
</tr>
</tbody>
{{question.options}}
</table>
<button ng-click="newOption(question)">Add Options</button>
</div>
js part:
$scope.questions = [
{
title: $scope.newTranslatable("Title"),
description: $scope.newTranslatable("Mr./Mrs./Ms."),
type: "list",
options: [
{
value: $scope.newTranslatable("Mr")
}, {
value: $scope.newTranslatable("Mrs")
}, {
value: $scope.newTranslatable("Ms")
}
]
}
$scope.removeOption = function(option) {
var index = $scope.questions.options.indexOf(option);
if(index != -1) {
$scope.questions.options.splice(index, 1);
}
}