-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
I would like to check if the user is logged in before letting him enter the state, so I am trying to use the resolve on the state defintion but always get this error: [$injector:unpr] Unknown provider: authorizedProvider <- authorized
Here is my example.component.js:
`
import template from './example.html';
import controller from './example.controller';
/*
* example Component
*/
const exampleComponent = {
restrict: 'E',
bindings: { },
template,
controller
};
export default exampleComponent;
`
Here is my example.controller.js:
`
/*
* Example Controller file
* @class
*/
class ExampleController {
/** @ngInject */
constructor( currentUser, authorized, $state) {
var self = this;
self.userIsLogged = authorized;
}
}
export default ExampleController;
`
Here is my example.js:
`
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import exampleComponent from './example.component';
const exampleModule = angular.module('example', [
uiRouter
])
.component('example', exampleComponent)
.config(($stateProvider, $urlRouterProvider) => {
'ngInject';
$urlRouterProvider.otherwise('/');
$stateProvider
.state('example', {
url: '/example',
template: '',
data: {
authorizedRoles: ['md', 'superuser']
},
resolve: {
authorized: function (currentUser) {
console.log(currentUser.logged);//this is a variable and it's true
return currentUser.logged;
}
}
});
})
.name;
export default exampleModule;
`
Metadata
Metadata
Assignees
Labels
No labels