Hi I want to append inputs to a html form.
My Html code is:
<div class="form-group">
<a
@click="addInput" class="btn btn-primary text-white btn-icon-split">
<span class="icon text-white-50">
<i class="fas fa-check"></i>
</span>
<span class="text">Add</span>
</a>
</div>
<div v-for="(input, index) in products, quantities">
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="exampleFormControlSelect1">Proveedor</label>
<select class="form-control" id="exampleFormControlSelect1"
v-model="products[index]"
>
<option :value="null">-Seleccionar-</option>
<option v-for="supplier_post in supplier_posts" :key="supplier_post.rut" :value="supplier_post.rut">{{ supplier_post.names }}</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Cantidad</label>
<input
type="number"
v-model="quantities[index]"
class="form-control"
placeholder="Ingresa la cantidad"
>
</div>
</div>
</div>
</div>
My VueJs code is:
data: function() {
return {
products: [],
quantities: []
}
},
methods: {
addInput() {
this.products.push(this.products.length+1);
this.quantities.push(this.quantities.length+1);
}
}
The problem that I have it is that every time that I push to the add button the inputs take a value 1, 2, 3 and I do not want that I'd like that if I click on add button it just add the inputs with a value nulled as default, how can I do that?
Thanks