Having trouble getting help?
Contact Support
Contact Support
Two way binding in Vue Numerictextbox component
11 Jun 20243 minutes to read
Two-way binding can be achieved by using the v-model
directive in Vue. In the following sample, when you change the value in one NumericTextBox component, v-model will automatically update the value in the other NumericTextBox.
The following example demonstrates how to set the two-way-binding
in the NumericTextBox.
<template>
<div id="app">
<div id="wrapper1">
<ejs-numerictextbox floatLabelType="Auto" placeholder="Enter a value" v-model="value"></ejs-numerictextbox>
</div>
<div id="wrapper2">
<ejs-numerictextbox floatLabelType="Auto" placeholder="Enter a value" v-model="value"></ejs-numerictextbox>
</div>
</div>
</template>
<script setup>
import { NumericTextBoxComponent as EjsNumerictextbox } from '@syncfusion/ej2-vue-inputs';
import { ref } from 'vue';
const value = ref(null);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material.css";
#wrapper1{
min-width: 250px;
float: left;
margin-left: 100px;
}
#wrapper2{
min-width: 250px;
float: right;
margin-right: 100px;
}
</style>
<template>
<div id="app">
<div id="wrapper1">
<ejs-numerictextbox floatLabelType="Auto" placeholder="Enter a value" v-model="value"></ejs-numerictextbox>
</div>
<div id="wrapper2">
<ejs-numerictextbox floatLabelType="Auto" placeholder="Enter a value" v-model="value"></ejs-numerictextbox>
</div>
</div>
</template>
<script>
import { NumericTextBoxComponent } from '@syncfusion/ej2-vue-inputs';
export default {
name: "App",
components: {
"ejs-numerictextbox": NumericTextBoxComponent
},
data: function () {
return {
value: null
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material.css";
#wrapper1 {
min-width: 250px;
float: left;
margin-left: 100px;
}
#wrapper2 {
min-width: 250px;
float: right;
margin-right: 100px;
}
</style>