How to extract query parameters with ui-router for AngularJS?(如何使用 AngularJS 的 ui-router 提取查询参数?)
问题描述
如何使用 ui-router 为 AngularJS 提取查询参数?
How do I extract query parameters using ui-router for AngularJS?
在 AngularJS 自己的 $location 服务中我做了:
In AngularJS' own $location service I did:
($location.search()).uid
($location.search()).uid
从 URL 中提取参数 uid.ui-router对应的代码是什么?
to extract the parameter uid from a URL. What is the corresponding code for ui-router?
推荐答案
除非您绑定到查询参数(请参阅文档),否则您不能直接通过 $state 或$stateParams.使用 $location 服务.
Unless you're binding to the query parameters (see the documentation), you don't access them directly through $state or $stateParams. Use the $location service.
每 docs,如果你想在 $stateParams 中捕获查询参数,你可以在你的 url 中附加一个 ? 并命名每个查询参数,用&分隔,即url: "/foo?bar&baz".
Per the docs, if you want to capture query parameters in $stateParams, you can append a ? to your url, and name each query parameter, separated by &, i.e. url: "/foo?bar&baz".
这篇关于如何使用 AngularJS 的 ui-router 提取查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 AngularJS 的 ui-router 提取查询参数?
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
