2017-06-20 101 views
0

想知道是否有一個內置的方式來獲得只有查詢字符串參數沒有額外的路由參數?角ui路由器 - 只獲取查詢字符串參數

實施例與$stateParamsdocs

// If you had a url on your state of: 
url: '/users/:id/details/{type}/{repeat:[0-9]+}?from&to' 

// Then you navigated your browser to: 
'/users/123/details//0' 

// Your $stateParams object would be 
{ id:'123', type:'', repeat:'0' } 

// Then you navigated your browser to: 
'/users/123/details/default/0?from=there&to=here' 

// Your $stateParams object would be 
{ id:'123', type:'default', repeat:'0', from:'there', to:'here' } 

我期待從/在這種情況下從靜止區分。

回答

0

$location.search()來自$location服務確實如此。從文檔

實施例:

// given URL http://example.com/#/some/path?foo=bar&baz=xoxo 
var searchObject = $location.search(); 
// => {foo: 'bar', baz: 'xoxo'}