我有以下状态:
.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¶mTwo //... });请参见文档
更多推荐
在ui路由器网址中查询字符串参数?
发布评论