The code in your rulesFactory
was only ever running once - the first time the service itself was instantiated.
It does this on resolve the first time:
- Angular sees it's looking for something to inject called 'rulesFactory'
- Angular finds a service called rulesFactory. It sees no one has used rulesFactory yet, and instantiates the service.
- The service rulesFactory is instantiated, and the $timeout is run with a promise returned
It does this on resolve the second time:
- Angular sees it's looking for 'rulesFactory'. rulesFactory already exists!
- Angular just gets the existing object for rulesFactory.
- The timeout has already run out from earlier, and the same already resolved promise will be used.
The fix for this is to have the rulesFactory return a function which will run the timeout again - every time you want it.
And additionally, $timeout itself returns a promise, so you can just return a $timeout :-)