The Full Controller

Listing 28.29 shows the full myApp code, with the shoppingController initialization and all the controller code together so you can see how everything fits together. Notice that the shoppingController definition includes dependencies on $scope, $http, and $window. The $window dependency allows you to add the browser alert message when errors occur.

Listing 28.29 cart_app.js-full: Implementing an application that supports keeping track of items in a shopping cart and handling the checkout process

001 var app = angular.module('myApp', []);002 app.controller('shoppingController', ['$scope', '$http', '$window',003                               function($scope, $http, $window) {004     $scope.months ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.