In my angular 1.5 app i try to call an authorisation service in order to predict the group of the current user.
I read the way to do so before the app is loaded is by adding to the routerProvider.
However i see it's not possible as the service wasn't initialised by then:
app.config(['$stateProvider', '$urlRouterProvider', '$compileProvider', 'authorizationService',
function ($stateProvider, $urlRouterProvider, $compileProvider, authorizationService) {
$compileProvider.preAssignBindingsEnabled(true);
$urlRouterProvider.otherwise('/');
$stateProvider.state('home', {
url: '/',
template: '<home-component></home-component>',
component: 'homeComponent',
params: {
selectedFilter: undefined
},
resolve: {
ldapGroup: function (authorizationService) {
return authorizationService.getLdapGroup().then(
function successCallback(data) {
$scope.isAdOps = data;
},
function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log(response);
}
);
}
}
})
I get:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:unpr] Unknown provider: authorizationService
Aucun commentaire:
Enregistrer un commentaire