O'Reilly logo

AngularJS Directives Cookbook by Fernando Monteiro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a shopping cart

In the previous chapter, we used an example of e-commerce to illustrate the operation of the Off Canvas menu, implementing a shopping cart. In this recipe, we will use a custom directive to add functionality to the Add to Cart and View Cart buttons.

Getting ready

Let's use the same example from the previous chapter, where we finalized with CSS customization.

How to do it…

  1. First off, we need to install the shopping cart directive. As in the previous recipe, we will install it with Bower. Open your terminal window at the project root and type the following command:
    bower install ngcart --save
    

    Tip

    If you do not use the Bower dependencies manager, you can add the directive to the project manually, as previously taught in earlier ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required