3

I have this line in my vue.js application

<input type="text" v-on:input="cssClass=$event.target.value">

I know that in javascript I can get event.target.value. I think that the above code is Vue.js specific code, but I'm not sure. Need confirmation.

3
  • you are using a custom attribute v-on:input... so it's not default to javascript Commented Jan 10, 2017 at 23:17
  • if I take out the dollar sign, the vue.js application doesn't work. So this is a vue.js code right? :) Commented Jan 10, 2017 at 23:17
  • sorry, I forgot to specify. I was wondering specifically about the '$event' part. Commented Jan 10, 2017 at 23:18

2 Answers 2

6

v-on:input will consume the actual DOM event of the input initially, store against $event, a special variable, and then make it available to the function being called. In this case you access $event.target.value to get the newly input value from the event. Methods in Inline Handlers

Hope that helps.

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

Comments

0

You can use $event because of VueJS. Angular2 also has the same special variable. What exactly $event object do in Angular 2?

Comments

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.