In this example you will build a simple time service that generates a local time object for different cities. Then in the AngularJS template you will use the time service in multiple controllers. The purpose is to give you a chance to see how easy it is to reuse an AngularJS service.
The code in Listing 10.3 implements a custom service named
TimeService using the function
TimeObj() to generate the service object. The code in
TimeObj simply defines a list of cities with a time zone offset and provides the
getCities() function creates an array of the cities represented and returns it.
Notice that there are several controllers added ...