angular -- $routeParams API翻譯


原api出處:

https://docs.angularjs.org/api/ngRoute/service/$routeParams

$routeParams 可以獲取當前路徑參數.

需要ngroute模塊被安裝

路徑參數是$location.search()和$location.path()的組合. 當$route被匹配的時候,路徑參數就會被獲取.

在參數名稱沖突的情況下,路徑參數優先於搜索參數

$routeParams服務保證當路由發生變化時,$routeParams對象的id不會變化(但是它的屬性很可能會變化)

請注意,$routeparams只有當路由完全改變成功后才會更新。這意味着在route的resolve函數里,你不能通過$routeparams獲取正確的路徑參數。但是,你可以使用$route.current.params訪問新路徑參數

 

Example

 // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby // 路由規則: /Chapter/:chapterId/Section/:sectionId // // 結果 $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'}



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM