Skip to content

Instantly share code, notes, and snippets.

@merqlove
Created August 18, 2014 06:54
Show Gist options
  • Save merqlove/4c604a75bbff7e818286 to your computer and use it in GitHub Desktop.
Save merqlove/4c604a75bbff7e818286 to your computer and use it in GitHub Desktop.
Global Resolve for Angular ngRoute
'use strict';
angular.module('app.routes')
.config(['$routeProvider', ($routeProvider) ->
angular.extend({}, $routeProvider, {
orgWhen: (path, route) ->
route.resolve ||= {}
route.resolve = _.merge(route.resolve, {
chef: 'OrganizationCheckerProvider'
})
$routeProvider.when.call(this, path, route)
})
# Organizations
.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