Implementing Helper Functions
Next, you add the helper functions, shown in Listing 28.22, to provide functionality for the AngularJS templates. The setContent()
function sets the $scope.content
value, effectively changing the view. The setProduct()
function is called when a user clicks a print image and sets the $scope.product
used in the product view. The cartTotal()
function iterates through the products in the user’s cart, updates $scope.shipping
, and returns a total that is then used in the cart and review views.
029 $scope.setContent = function(filename){030 $scope.content = '/static/'+ filename; ...
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.