You want to bring it to the controller level.
In this example, I redefine whole pages as well as partial subdomains:
app.js
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $locationProvider.html5Mode(true); $routeProvider.when('/', { template: 'home' }); $routeProvider.when('/contact', { template: 'contact' }); $routeProvider.otherwise({redirectTo: '/'}); }])
controllers.js
controller('AppController', ['$scope','Views', function($scope, Views) { $scope.$on("$routeChangeSuccess",function( $currentRoute, $previousRoute ){ $scope.page = Views.returnView(); }); $scope.returnView = function(partial){ return Views.returnView(partial); } }])
services.js
factory('Views', function($location,$route,$routeParams,objExistsFilter) { var viewsService = {}; var views = { subdomain1:{ 'home':'/views/subdomain1/home.html' }, subdomain2:{ }, 'global.header':'/views/global.header.html', 'global.footer':'/views/global.footer.html', 'home':'/views/home.html', 'home.carousel':'/views/home.carousel.html', 'contact':'/views/contact.html', }; viewsService.returnView = function(partial) { var y = (typeof partial === 'undefined')?$route.current.template:partial; var x = $location.host().split("."); return (x.length>2)?(objExistsFilter(views[x[0]][y]))?views[x[0]][y]:views[y]:views[y]; }; viewsService.returnViews = function() { return views; }; return viewsService; }).
filters.js
filter('objExists', function () { return function (property) { try { return property; } catch (err) { return null } }; });
index.html
<!doctype html> <html lang="en" ng-controller="AppController"> <body> <ng-include src="returnView('global.header')"></ng-include> <ng-include src="page"></ng-include> <ng-include src="returnView('global.footer')"></ng-include> </body> </html>