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,534
  • 1
  • 20
  • 27
Simon Suh
  • 9,835
  • 23
  • 83
  • 103

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.

Community
  • 1
  • 1
Searching
  • 2,259
  • 1
  • 16
  • 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