Angular UI Router使用参数重定向到Abstract状态

时间:2016-07-20 15:24:33

标签: angularjs angular-ui-router

我有以下状态。

.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 }
})

我希望能够将用户重定向到:

  

/工作流/的:workflow_id /视图

我尝试了以下操作,但由于启用了abstract :true,因此一直收到以下错误:

  

错误:无法转换为抽象状态'workflow2'

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

有谁知道如何将用户重定向到我的“查看”状态?

1 个答案:

答案 0 :(得分:0)

试试这个

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