17

I'm new with Vue.js and I'm trying to test some features of this framework. Now I'm testing the input forms, and I would like to make a one-way binding, without using the v-model directive, but I can't find any example. Anyone could help me, please?

1 Answer 1

25

Here is example of one way and two way binding

var V = new Vue({
  el:'#vue-instance',
  data:{
    name:'Niklesh'
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.4/vue.js"></script>
<div id="vue-instance">
<div>One Way binding with input box <input type="text" :value="name"></div>
<div>One Way binding as text {{name}}</div>

<div>Two way binding : <input type="text" v-model="name"></div>
</div>

Sign up to request clarification or add additional context in comments.

24 Comments

Ok thank you! Another question, how can I set the initial data from an asyncronous function and then get the value on submit in vue.js one-way binding?
@Nuovo001: You need to add just like in pure javascript as by id or name or any seelctor to to formData which you are going to post as formData.name=$("#name").val() before submit.
@Nuovo001: what is the situation to not use v-model ?
@Nuovo001 : one way binding is to display text, and two way is for user input, its good to use two way if you are taking user input.
@WaldemarIce : What it should be to make two way data-binding according to doc ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.