Angular - 如何使用 $state 访问多个 url 参数

Angular - how to access multiple url parameters using $state

我在 Angular 路由中有以下状态:

.state("supplier/document", {
            url: "/supplier/document/:supplierid/:docid",
            controller: "ctrlSupplierDocument",
            templateUrl: "views/supplier/document.html"})

然后我使用以下代码进入此状态:

$state.go('supplier/document', { 'supplierid': $scope.supplierid, 'docid': item.QualificationID });

这导致我正确地转到有问题的视图,url 格式符合预期:

http://localhost:60437/index.html#/supplier/document/14/70

我现在需要从 url 中获取两个 ID(14 是供应商 ID,70 是文档 ID)。但是 $state.params 是未定义的(显然它没有将这些视为 GET 参数)。通常,使用一个参数 $state.param.id 就可以正常工作。这里的区别是两个参数。

问。我如何获取这些参数?或者是否有另一种方法可以实现此目的,我可以在目标视图控制器上使用 $state.params?

谢谢!

尝试:$state.current.params.supplierid$state.current.params.docid

参见:http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state