Skip to content

Instantly share code, notes, and snippets.

@gnomeontherun
Created August 8, 2013 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnomeontherun/6188050 to your computer and use it in GitHub Desktop.
Save gnomeontherun/6188050 to your computer and use it in GitHub Desktop.
Demonstration of AngularJS and how to define a batch of routes without declaring each directly with $routeProvider.
var routes = [
{
url: '/',
params: {
templateUrl: 'views/home.html',
controller: 'HomeCtrl'
}
},
{
url: '/bookmarks',
params: {
templateUrl: 'views/bookmarks.html',
controller: 'BookmarksCtrl'
}
},
{
url: '/search',
params: {
templateUrl: 'views/search.html',
controller: 'SearchCtrl'
}
}
];
angular.module('MyApp', [])
.config(function ($routeProvider, $locationProvider) {
angular.forEach(routes, function (route, index) {
$routeProvider.when(route.url, route.params);
});
$routeProvider
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment