Directing Angular Directives
Over the last few months, I've been digging into the Angular framework. One of the things that I really like about Angular, and hope to learn to use extremely well as I progress, is their notion of a "Directive". Directives provide a means for extending both the semantic meaning and functionality of your markup. There are many different ways to implement directives, and the documentation on the angular site is still a work in progress, so I would like to share how I've used them up to this point.
The Goal: Creating a reusable donut chart and legend
First, we have to think about how we're going to get data to feed to the chart. So, I created a quick module that contains a "Product Line", which contains "Products". The plan is to be able to use a single controller and view to be able to see a donut chart and legend for both a single Product, and the full Product Line.
Each Product has a raw goods cost, shipping cost, and markup amount. The singleton that is the Product Line has a way to get aggregated data from all products, for viewing overall costs in those categories. I then created a service for my angular app to interact with this module.
Your new post is loading...