In the app.run method, you can use the $ routeChangeStart event to intercept only until the route is completed. In your .config, specify templateURL as the file of the template itself (e.g. home.html, without / views)
app.config(function ($routeProvider) { $routeProvider .when('/', { templateUrl: 'home.html', controller: 'HomeCtrl' }); ... });
and then you can add the following code to .run:
app.run(function ($rootScope,$location){ $rootScope.$on('$routeChangeStart',function(event,next,current){ next.templateUrl = "views/"+$location.host()+"/"+next.templateUrl; }); });
and it will access home.html in the view / <host> /home.html
Plunger example: http://embed.plnkr.co/82qV7uCZOBgZxjahhlU3/ Note that I use _ instead of / to simulate the directory in which the file is located, based on the host name. Plunker does not like / in the file name (refused to save the file, although I was able to run it)
source share