Depending on the logic in services, I route to different views. To facilitate service injection, I use a loading controller to determine where to go next.
This works great, except that I can't go "back" through a loading controller. How do I either detect the back button, or fix my loading model to be more friendly to it?
.when('/loading', { templateUrl: '/app/views/mystuff/loading.html', controller: 'LoadingController' }) angular.module('app').controller('LoadingController', ['$location', 'WhereService', function ($location, WhereService) { if (!WhereService.doneWithA()) { $location.path('/a'); } else if (!WhereService.doneWithB()) { $location.path('/b'); } else { location.href = "/myapp/somewhereelseentirely"//this is fine } }]); angular.module('app').controller('ALoadingController', ['$location', 'AService', function ($location, AService) { if (!AService.isDone()) { $location.path(AService.currentPath()); } else { $location.path('/');//triggers loading controller above } }]);
/loadingroute where theLoadingControllertakes over and navigates you back to the current view? If this is the case, doing$location.replace()before each$location.path('...')in theLoadingControllermay help.