Code Editor
Web Browser
Learn

Great! Each time you click on the number of likes, the number goes up. How does it work?

  1. The ng-click is a directive. When <p class="likes"> is clicked, ng-click tells AngularJS to run the plusOne() function in the controller.
  2. The plusOne() function gets the index of the product that was clicked, and then adds one to that product's likes property.

Notice that the plusOne() doesn't interact with the view at all; it just updates the controller. Any change made to the controller shows up in the view.

Report a Bug
If you see a bug or any other issue with this page, please report it here.