5

<input type="text" placeholder="{{fromTimeWindow}}" v-model="fromTimeWindow"/>

or<input type="text" v-bind:placeholder="{{fromTimeWindow}}" v-model="fromTimeWindow"/>

both of the above above code gives me error. I want to use variable "fromTimeWindow" value as placeholder.

1
  • 1
    Just use v-bind:placeholder="fromTimeWindow". You can't use moustache in attribute value binding anyway. Commented Feb 21, 2020 at 8:52

3 Answers 3

9

You dont have to {{ }} since you are binding it to your placeholder. To solve that change your code to this.

<input type="text" :placeholder="fromTimeWindow" v-model="fromTimeWindow"/>
Sign up to request clarification or add additional context in comments.

Comments

3

new Vue({
el: '#app',
data: () => {
  return {
    fromTimeWindow: 'Hey here is custom placeholder'
    }
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input type="text" :placeholder="fromTimeWindow" />
</div>

Comments

1

Ahhh.. Got the answer from : Vue.js change placeholder of text input according to v-model value .

We need to use it like this:

<input type="text" :placeholder="[[fromTimeWindow]]" v-model="fromTimeWindow"/>

2 Comments

You dont even need [[]] scope
yeah. removed it after your comment. Thanks :)

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.