Last active
September 16, 2015 08:34
-
-
Save lnaia/3d9f02545660814e2294 to your computer and use it in GitHub Desktop.
Hosts module config
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
(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