This lesson talks about the benefits of using the parens-based (click)
syntax so that Angular 2 can handle any custom event. Then the video explains how to pass in the actually event object using the familiar $event
syntax.
[00:00] If you need to get the actual MouseEvent, you can use the "$Event" syntax, which is just the same way we did it in Angular 1, so that the Event will be passed along. Now this value is the actual MouseEvent, so now when I click on this button, you'll see MouseEvent with all the properties you would expect from the MouseEvent.
[00:19] After that Event, you can go ahead and type ", myInput.value" and as well say that this is the Event, and we want to log out the Event, and then the value, so the "$Event" is here, the input value is here, and we're logging out the Event and the value. Now when we click and I type something, "Hello," and click, you'll see the MouseEvent and the value of "Hello."
[00:45] This will work on any DOM Event. If you were to say "mouseover" and hit save, now instead of onclick, every time I mouse over this button, you'll see those MouseEvents firing, and the value "Hello" of the form logging out as well.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!