在ui路由器网址中查询字符串参数?

编程入门 行业动态 更新时间:2024-10-27 12:28:22
本文介绍了在ui路由器网址中查询字符串参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下状态:

.state('quotes', { abstract: true, url: '/quotes' }) .state('quotes.new', { url: '/new', templateUrl: 'views/quote-form.html', controller: 'QuoteFormCtrl' }) .state('quotes.new.customer', { url: '?customer', templateUrl: 'views/quote-form.html', controller: 'QuoteFormCtrl' })

当我点击URL /quotes/new?customer=123时,剥离了客户查询字符串,而我仍然处于quotes.new状态.

When I hit the URL /quotes/new?customer=123 the ?customer query string is stripped off, and I am left at the quotes.new state.

对我来说最有意义的只是在quotes.new状态定义中添加params: ['customer'],但这使我犯了一个错误,抱怨我同时指定了url和params.

What would make most sense to me is just adding a params: ['customer'] to the quotes.new state definition, but that gives me an error complaining that I specify both url and params.

任何关于我正在尝试做的事的例子都将不胜感激.

Any examples of what I'm trying to do would be much appreciated.

推荐答案

您应该修改url字符串属性以包括您的customer查询参数,如下所示:

You should modify the url string property to include your customer query parameter, like this:

.state('quotes.new', { url: '/new?customer', templateUrl: 'views/quote-form.html', controller: 'QuoteFormCtrl' });

可以通过使用&分隔多个参数来添加多个参数:

Multiple parameters can be added by separating them with an &:

.state('mystate', { url: '/myState?paramOne&paramTwo //... });

请参见文档

更多推荐

在ui路由器网址中查询字符串参数?

本文发布于:2023-11-13 01:18:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583010.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   路由器   参数   网址   ui

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!