Skip to content

Instantly share code, notes, and snippets.

@rbinsztock
Forked from merqlove/routes.coffee
Created August 19, 2015 08:04
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 rbinsztock/95caef3347bb6943d1ca to your computer and use it in GitHub Desktop.
Save rbinsztock/95caef3347bb6943d1ca to your computer and use it in GitHub Desktop.
Global Resolve for Angular ngRoute
'use strict';
angular.module('app.routes').config([
'$routeProvider', function($routeProvider) {
return angular.extend({}, $routeProvider, {
orgWhen: function(path, route) {
route.resolve || (route.resolve = {});
route.resolve = _.merge(route.resolve, {
chef: 'OrganizationCheckerProvider'
});
return $routeProvider.when.call(this, path, route);
}
}).when('/organizations', {
templateUrl: '/templates/organizations/index.html',
controller: 'OrganizationsCtrl',
controllerAs: 'orgs'
}).when('/organizations/new', {
templateUrl: '/templates/organizations/new.html',
controller: 'OrganizationsNewCtrl',
controllerAs: 'org'
}).orgWhen('/organizations/:organizationId', {
templateUrl: '/templates/organizations/show.html',
controller: 'OrganizationsShowCtrl',
controllerAs: 'org'
}).orgWhen('/organizations/:organizationId/edit', {
templateUrl: '/templates/organizations/edit.html',
controller: 'OrganizationsEditCtrl',
controllerAs: 'org'
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment