Skip to content

Instantly share code, notes, and snippets.

@mort3za
Created July 27, 2015 14:47
Show Gist options
  • Save mort3za/5860e9c0abf0a5bc2ffb to your computer and use it in GitHub Desktop.
Save mort3za/5860e9c0abf0a5bc2ffb to your computer and use it in GitHub Desktop.
UI-Router sample, With a root template and child views. Note that URL of homepage is `/` and root has no URL.
/* Setup Rounting For All Pages */
SApp.config(['$stateProvider', '$locationProvider', '$httpProvider', '$urlRouterProvider', function($stateProvider, $locationProvider, $httpProvider, $urlRouterProvider) {
$httpProvider.defaults.withCredentials = false;
$locationProvider.html5Mode(true);
// Redirect any unmatched url
$urlRouterProvider.when('', '/');
$urlRouterProvider.otherwise("/");
// get app language
var current_lang = AppSettings.get().CURRENT_LANG;
$stateProvider
.state('root', {
templateUrl: "root." + current_lang + ".html", // e.g. root.en.html
controller: "AppController",
})
// home
.state('root.home', {
url: "/",
views: {
'main-content': {
templateUrl: "main-content." + current_lang + ".html",
controller: "HomeMainContentController as hmcCtrl"
},
'site-header': {
templateUrl: "site-header." + current_lang + ".html",
},
'mega-menu': {}
}
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment