angularjs - Build link with parameter (?key=val) with ui-sref directive -
i'm using angular ui-router, state like:
.state('detail', { url: '/detail/{id}',
in html file prefer use ui-serf directive build link. example:
<a ui-sref="detail( { id:123 } )">...
how can build link optional query parameter? example:
/detail/123?mode=json&pretty=true
i think ui-router
way it's not use query parameters, instead of doing:
/detail/123?mode=json&pretty=true
declare state as
.state('detail', { url: '/detail/{id}/{format}/{pretty}', ...
and using like:
/detail/123/json/true
anyway, if want use query format, can out-of-the-box state in doc:
you can specify parameters query parameters, following '?':
url: "/contacts?myparam" // match url of "/contacts?myparam=value" if need have more one, separate them '&':
url: "/contacts?myparam1&myparam2" // match url of "/contacts?myparam1=value1&myparam2=wowcool"
see: https://github.com/angular-ui/ui-router/wiki/url-routing#query-parameters
Comments
Post a Comment