On server side i have a next method, which check if token found in database:
def method(token)
if (Database.find(token).length == 0)
not_found()
else
success()
end
url as token/:token, for example token/123
I have a state for it:
$stateProvider.state('token', {
url: '/token/:token',
templateUrl: 'success'
}).state('404', {
url: '/404',
templateUrl: 'notfound'
});
But i do not know, how to in ui router check token, i need some like this
$http.post('/token', {token: $stateParams.token}).success(function(){
//ok continue and load `success` template
}).error(function(){
$state.go('404'); //when error
});
Is it possible with ui router?