Duration: 19 min
Summary: In this lesson, we are going to talk about events. I will start with our basic controller that we’ve been working with (book controller). After loading the data in a table, we will demonstrate how to use the ng-class-even and ng-class-odd to style the rows within the table. Then, we will add ng-mouseenter, ng-mouseleave, and ng-click to the mix. But that needs some more information added to the scope. Specifically, I am going to add a function that handles the events for me. I will call that function within the row’s ng-mouseenter and ng-mouseleave. For the ng-click, I will add a ‘data’ variable to the scope. That data contains the CSS class I am interested in. To start with, the class is empty. It will be populated when the user clicks on the button. The result is highlighting the even rows in the table. I will also show how to use the developer tools to see the mouse enter and mouse leave in action since the function is handling this by writing to the log.