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.

Sage
  • 4,769
  • 1
  • 21
  • 28
Simon Suh
  • 10,599
  • 25
  • 86
  • 110

2 Answers2

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.

tony19
  • 125,647
  • 18
  • 229
  • 307
Searching
  • 2,269
  • 1
  • 17
  • 28
0

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

Community
  • 1
  • 1
FNunez
  • 98
  • 2
  • 12