繁体   English   中英

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

现在,我需要从网址中获取两个ID(14是Supplierid,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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM