I have two kinds of states in my $stateProvider which are authenticated user access url and public access url..
I have some sort of urls in public access , the thing is i need to prevent these url to access of authenticated user and need to change the url with another one.
Example Suppose, http://localhost:3000/#/pjobadd/1 is public access url, if authenticated user will access this url i need to change as http://localhost:3000/#/jobadd/1 .
I'm trying to take the solution as bellow
i have attached parameter in state provider like
.state('admin-panel.public.jobadd', {
url: '/pjobadd/:jobID',
templateUrl: 'app/public/jobadd.tmpl.html',
controller: 'PublicJobaddController',
resolve: {
jobAdd: ['Public', '$stateParams', function(Public,$stateParams) {
return Public.jobAdd($stateParams.jobID);
}]
},
data: {
requireChange: 'pjobadd'
}
})
and used that requireChange in app.js as following
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
if (!Auth.isAuthenticated()){
var requireChange = toState.data.requireChange;
console.log(requireChange);
switch(requireChange){
case 'pjobadd':
$state.go('admin-panel.default.jobadd');
case 'psearch':
$state.go('admin-panel.default.search');
}
There are issues i need to append the url passed parameters and $state.go() also not redirecting to the mentioned url. i don't think that it'l be the efficient way.
Can anyone suggest a way to it???