I'm doing an application in which there are some field and the user can adds new rows with new (same) fields.
I need to let the user add an option to select. I know how to make in jQuery, but I'm not able to integrate with Angular. If you see the plnkr CODE
you can see that there are one select and the last one is "+". When the user click on it, the input from where to get the text for new option should appear. This is the code for the showing, it should change class but it doesn't work because the input type is always inline:
$(".new").on("click", function () {
var state = $(this).data('state');
state = !state;
if (state) {
$("new-option").addClass("hide");
} else {
$("new-option").removeClass("show");
}
$(this).data('state', state);
});
This is the code for the new option:
<div class="new-option">
<label> New Option </label>
<input type="text" data-ng-model="food.newOption">
<button onClick="add()">Add</button>
<script language="JavaScript">
function add() {
var newOption = '<option value="lol">' + $scope.food.newOption + '</option>';
$('.new').append(newOption);
}
Can somebody help me to change the class on " + " pressing, and add the filled input in a new option?
Thank you in advice!