in the below example i have variable called roles
inside data
for this variable i have to add array of roles. now i in the second state have predefined the roles but this role array i have to take load from the web api.
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('signin');
$stateProvider.state('site', {
'abstract': true,
resolve: {
authorize: ['authorization', function (authorization) {
alert(JSON.stringify(authorization))
return authorization.authorize();
}, ]
}
})
.state('signin', {
parent: 'site',
data: {
roles: []
},
url: '/signin',
views: {
'': { templateUrl: '/signin.html' },
'content@': {
templateUrl: '/index.html',
controller: 'SigninCtrl'
}
}
})
.state('WorkArea', {
parent: 'site',
url: '/WorkArea',
data: {
roles: ['User', 'Dev']
},
views: {
'': { templateUrl: '/Views/WorkArea/WorkArea.html' },
'ContentOne@': {
templateUrl: '/Views/WorkArea/ProjectList.html',
controller: 'ProjectController'
}
}
})
}]);
i am referring this example from below link:-