Skip to content

Instantly share code, notes, and snippets.

@lnaia
Last active September 16, 2015 08:34
Show Gist options
  • Save lnaia/3d9f02545660814e2294 to your computer and use it in GitHub Desktop.
Save lnaia/3d9f02545660814e2294 to your computer and use it in GitHub Desktop.
Hosts module config
(function() {
'use strict';
angular
.module('edustorage.hosts')
.config(configure);
configure.$inject = ['$routeProvider'];
function configure($routeProvider) {
$routeProvider.when('/hosts', {
templateUrl: '/myapp/hosts/list.html',
controller: 'hostsCtrl',
controllerAs: 'hosts',
resolve: {
auth: ['authenticationService', '$q', function (authenticationService, $q) {
var auth = authenticationService.verifyAuthentication();
if (auth) {
return $q.when(auth);
} else {
return $q.reject({ authenticated: false });
}
}]
}
});
$routeProvider.when('/hosts/new', {
templateUrl: '/myapp/hosts/new.html',
controller: 'newhostCtrl',
controllerAs: 'newhost',
resolve: {
auth: ['authenticationService', '$q', function (authenticationService, $q) {
var auth = authenticationService.verifyAuthentication();
if (auth) {
return $q.when(auth);
} else {
return $q.reject({ authenticated: false });
}
}]
}
});
$routeProvider.when('/hosts/:id/edit', {
templateUrl: '/myapp/hosts/edit.html',
controller: 'edithostCtrl',
controllerAs: 'edithost',
resolve: {
auth: ['authenticationService', '$q', function (authenticationService, $q) {
var auth = authenticationService.verifyAuthentication();
if (auth) {
return $q.when(auth);
} else {
return $q.reject({ authenticated: false });
}
}]
}
});
$routeProvider.when('/hosts/:id', {
templateUrl: '/myapp/hosts/single.html',
controller: 'hostCtrl',
controllerAs: 'single',
resolve: {
auth: ['authenticationService', '$q', function (authenticationService, $q) {
console.log('resolve.authenticationService ok');
var auth = authenticationService.verifyAuthentication();
if (auth) {
return $q.when(auth);
} else {
return $q.reject({ authenticated: false });
}
}]
}
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment