Implementing Configuration and Run Blocks

Listing 3.5 shows an example of implementing very basic configuration and run blocks. In lines 2–8, the config() method is used to implement two providers, configTime and runTime, that are JavaScript Date objects. Notice that in lines 5–7 a simple loop is implemented to inject a delay simulating a delay that might be caused during configuration.

In lines 9–11 the run() method is implemented. Notice that it accepts the configTime and runTime instances that were created during configuration and updates the runTime value to the current time. Then in Lines 12–16 a controller is implemented that sets the configTime and runTime values in the scope.

Listing 3.6 shows HTML that implements the myApp module and ...

Get Learning AngularJS 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.