In an AngularJS web application, a controller requires some data for initialization,
but this data needs to be retrieved from server. One solution is that after controller is initialized,
$http service to get the data and returns a
deferred. But this will change the usage of data to asynchronous operation,
which may not be possible for all the operations. People usually prefer to synchronous operations. Another solution is to delay initialization of controller
until data is retrieved from server successfully.
To do this, we need to use a
run service to start retrieval of the data.