bryan bryan - 4 months ago 43
AngularJS Question

Angular UI Router Redirecting to Abstract state with parameter

I have the following states.

.state('workflow2', {
abstract: true,
url: '/workflow/:workflow_id',
views: {
'main': {
templateUrl: 'pages/templates/view_workflow.html',
controller: 'view_workflow'
},
},
resolve: { authenticated: authentication }
})

.state('workflow2.view', {
url: '/view',
templateUrl: 'pages/templates/workflow/view.html',
controller: 'workflow.view',
resolve: { authenticated: workflow_item_auth }
})


I'd like to be able to redirect my user to:


/workflow/:workflow_id/view


I've tried the following but keep getting the following error because I have
abstract :true
enabled:


Error: Cannot transition to abstract state 'workflow2'


$state.go('workflow2', {workflow_id: id});
$state.go('workflow2.view', {workflow_id: id});


Does anyone know how I can redirect a user to my "view" state?

Answer

try this

.state('workflow2.view', { 
  url: '/:workflow_id/view', 
  templateUrl: 'pages/templates/workflow/view.html', 
  controller: 'workflow.view', 
  resolve: { authenticated: workflow_item_auth }
})