By now, we have covered pretty much all the different parts of the Angular, including directives, services, controllers, resources, and so much more. But even we know that sometimes just reading about it isn’t enough. And sometimes we don’t care about how any of that works, we just want to know how to do that one thing with AngularJS?
In this chapter, we take a stab at giving complete coding samples (with little bits of info and pointers to explain what is happening) for some common problems we tackle in most web apps. They are in no particular order, so feel free to jump to whichever ones you care about, or go through them in order. You are the boss!
The examples covered in this chapter include:
This example can be found in chapter8/datepicker on our GitHub page.
Even before we jump into the code, we have to decide how our component is going to look and work. Let’s say we want to define our datepicker in HTML as follows:
<input datepicker ng-model="currentDate" select="updateMyText(date)"></input>
That is, we want to modify the Input field by adding an attribute datepicker, and adding some more functionality to it (like data binding with the model and the ability to be notified when a date is selected). So how would we go about it?
We will re-use ...