最近在改造别人代码,要把ngRouter换成ui-router,在获取参数的时候遇到了一个坑,先随便写写,有空再完善
// Given:
// URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
// Route: /Chapter/:chapterId/Section/:sectionId
//
// Then
$routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'}
1、
// Given:
// URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
// Route: /Chapter/:chapterId/Section/:sectionId
//
// Then
$stateParams==> {chapterId:'1', sectionId:'2'}
2、
// Given:
// URL: http://server.com/index.html#/Chapter/1/Section/2
// Route: /Chapter/:chapterId/Section/:sectionId?search&type
//
// Then
$stateParams==> {chapterId:'1', sectionId:'2'}