I'm passing a web system that has Jquery to Angular 2. I have a button that when clicked it adds two inputs and together with them a button is created to exclude these inputs. (follow the code in Jquery) ...
//Adiciona campos extra nos sócios
var campos_max = 10; //max de 10 campos
var x = 1; // campos iniciais
$('#add_field').click (function(e) {
e.preventDefault(); //prevenir novos clicks
if (x < campos_max) {
$('#listas').append('<div>\
<div class="form-group">\
<label class="col-sm-2 control-label">Nome sócio:</label>\
<div class="input-group">\
<span class="input-group-addon">*</span>\
<input class="form-control socio" name="nome[]" type="text" placeholder="Nome sócio..." required>\
</div>\
</div>\
<div class="form-group">\
<label class="col-sm-2 control-label">Participação (%):</label>\
<div class="input-group">\
<span class="input-group-addon">*</span>\
<input class="form-control socio part" name="participacao[]" type="text" placeholder="Participação..." required number="true">\
</div>\
</div>\
<input href="#" type="button" id="add_field" value="Remover campo" class="remover_campo btn btn-warning">\
</div>');
x++;
}
});
// Remover o div anterior
$('#listas').on("click",".remover_campo",function(e) {
e.preventDefault();
$(this).parent('div').remove();
x--;
});
Doubt is, how to do this in angular 2? I tried to find something to add with ElmentRef, but not to delete it.