簡體   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