Skip to content

Instantly share code, notes, and snippets.

@kapv89
Created June 19, 2013 20:11
Show Gist options
  • Save kapv89/5817622 to your computer and use it in GitHub Desktop.
Save kapv89/5817622 to your computer and use it in GitHub Desktop.
a sample router
angular.module('sorter').config(function ($routeProvider, $locationProvider) {
// code fuplicated here, cos can't find a way to use custom service in config
var $uri = (function () {
var pageBase = '/admin/classification/sorter/app/', tmplBase = '/js/sorter/tmpls/',
apiBase = '/admin/classification/sorter/api/'
return {
page: function (uri) { return pageBase + uri; },
tmpl: function (uri) { return tmplBase + uri; },
api: function (uri) { return apiBase + uri; }
};
})();
/// probably can be done using a util module, but i am just flying atm
/////////////////////////////////////////////////////////////////
$routeProvider
.when($uri.page('artists'), {
resource: 'artists',
listingTmpl: $uri.tmpl('artists/index.html'),
})
.when($uri.page('events'), {
resource: 'events',
listingTmpl: $uri.tmpl('events/index.html')
})
.when($uri.page('songs'), {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment