Created
August 18, 2014 06:54
-
-
Save merqlove/4c604a75bbff7e818286 to your computer and use it in GitHub Desktop.
Global Resolve for Angular ngRoute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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