Events allow you to respond to all sorts of user input. Angular has a special notation to deal with events. Learn how you can use parentheses to track any event within an HTML element.
- [Instructor] One of the most important things to learn…when developing any application is how to deal with events.…Events allow you to respond to all sorts of user input…and AngularJS has a special notation…and templates that let you handle events.…So let's go ahead and add an event in our app about HTML…to capture a click on one of these names.…So to do that, I'm going to do it right after this LI…right here and I can capture a click event by using…parentheses and then typing in the name of the event.…
In this case, it would be click and then…when that event happens, we can run a method…and we're going to call this one onClick.…And then we'll pass along the event…information using this dollar sign.…So whenever we click, it's going to run this event.…Let's go ahead and save this and…then we'll go into component and right around here,…I'm going to create that method onClick.…Then, we're going to capture the event…in a variable we'll call e and for right now let's just…go ahead and log it to the console.…
So we'll go ahead and save that,…
In this course, Ray Villalobos shows you how to start using Angular 2 in your own projects. He starts by defining what exactly Angular 2 is and how it differs from AngularJS 1. Then, once the basics are out of the way, he sets up the template that will drive the project and starts coding. Ray shows how to divide your project into modules, work with events, style content with CSS, and create components and subcomponents. Plus, you can find out how to change content dynamically using data pipes.
Note: Members can find a template to download in the exercise files.
- What is Angular 2?
- Setting up a template
- Creating a simple component
- Using multiple modules
- Displaying data in templates
- Working with events
- Creating a subcomponent
- Filtering content through data pipes