Skip to Main Content
AngularJS Web Application Development Blueprints
book

AngularJS Web Application Development Blueprints

by Vinci J Rufus
August 2014
Intermediate to advanced content levelIntermediate to advanced
300 pages
6h 9m
English
Packt Publishing
Content preview from AngularJS Web Application Development Blueprints

Summarizing the expenses by categories

Getting back to our application, as we want to create a graph showing the summary of expenses for each category, we will first need to calculate the total expense made under each category.

We will start by creating a function within our factory service that will total up the expenses for a category name that is passed to it.

Open up the app/js/services.js file, and add the following function within the return {} section of the expService factory:

getCategoryTotal: function(category) { var categoryTotal = 0; var prefixLength = prefix.length; Object.keys(localStorage) .forEach(function(key) { if (key.substring(0, prefixLength) == prefix) { var item = localStorage[key] item = JSON.parse(item) if (item.category ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AngularJS: Maintaining Web Applications

AngularJS: Maintaining Web Applications

Rodrigo Branas, Chandermani, Matt Frisbie, Amos Q. Haviv
AngularJS

AngularJS

Shyam Seshadri, Brad Green
Professional AngularJS

Professional AngularJS

Valeri Karpov, Diego Netto
Pro AngularJS

Pro AngularJS

Adam Freeman

Publisher Resources

ISBN: 9781783285617Supplemental Content