From http://stackoverflow.com/questions/19037179/angular-synchronous-http-loop-to-update-progress-bar