I am able to add textbox dynamically on button click. My problem is i cant set dynamic id and value.
<div id="app">
<div>
<button class="button btn-primary" @click="addRow">Add row</button>
</div>
<div v-for="row in rows">
<button-counter></button-counter>
</div>
</div>
<script>
Vue.component('button-counter', {
template: '<input type="text" style="margin-top: 10px;" ><br>'
})
var app = new Vue({
el: "#app",
data: {
rows: [],
count:0
},
methods: {
addRow: function () {
var txtCount=++this.count;
id='txt_'+txtCount;
this.rows.push({ title: "first", description: "textbox1" });
}
}
});
</script>
This is my code.
I have created on component for input and created one vue instance.while clicking add row button, it will add a new textbox.but i dont know to bind id and value for textbox.