From the course: Learning Angular

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with events

Working with events - Angular Tutorial

From the course: Learning Angular

Start my 1-month free trial

Working with events

- [Instructor] Managing user input is an important part of any application. Angular shows you how to bind events to a component using a special notation in your template. So let's take a look at how that works. Now to use an event in your template, you simply include the event name inside parenthesis. You can then bind this event to a method in your component and inside that method you can do whatever you need to do. You can use a special variable called event with a dollar sign to pass along the event itself as a parameter to that method, although it's not necessarily a good idea to do that since it does include a lot of information. Now you can also pass in along any data from the template in order to do things with that data. Now this is how you make your template talk to your computer logic. So right now let's take a look at our template which is right here and what we want to do is add a click event so that when somebody clicks on any of these elements, I'm going to update this…

Contents