提取URL查询参数与AngularUI [英] Extract URL query parameters with AngularUI
问题描述
我使用AngularUI库,并希望从URL中提取查询参数与
(样品网址:#\\书\\:?的categoryID出版商= XYZ
(#\\书\\值出版商= XYZ
))。
I am using AngularUI library and want to extract the query parameters with from a URL
(sample URL: #\books\:categoryID?publisher=xyz
(#\books\value?publisher=xyz
)).
的 $ stateParams
提取数据为 {的categoryId:值出版商= XYZ}
,但我需要得到为 {的categoryId:值,出版:XYZ}
The $stateParams
extracts the data as {categoryId:value?publisher=xyz}
but I need to get it as {categoryId:"value", publisher:"xyz"}
.
在此先感谢
推荐答案
角 UI路由器
具有传递参数作为查询字符串PARAMS直接支持。有一个文档
Angular ui-router
has direct support for passing parameters as a query string params. There is a doc
- URL参数 - 查询参数
- URL Parameters - Query Parameters
有是一个例子,在此状态下定义的链接:
There is a link to an example, using this state definition:
$stateProvider
.state('books', {
url : '/books/:categoryID?publisher',
template: '<div> This is a state def: '+
'<pre>{{toNiceJson(state)}}</pre>' +
' These are params sent to this state:' +
'<pre>{{toNiceJson(params)}}</pre>'+
' </div>',
controller: 'urlParamsCtrl',
})
而这些可能是链接到那个状态
And these could be links to get to that state
<a href="#/books/value?publisher=xyz">...
<a href="#/books/other?publisher=unknown%20publisher">...
<a ui-sref="books({categoryID:'value', publisher:'xyz'})">...
<a ui-sref="books({categoryID:'other', publisher:'unknown publisher'})">...
查看更多 rel=\"nofollow\">
See more here
这篇关于提取URL查询参数与AngularUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!