例如.这是已经存在的.state('site.link1',{网址:'/link1',templateUrl: '/views/link1.html',控制器:'link1Ctrl'})并且请求是添加指向link1页面的www.site.com/newlink.有没有这样的;.state('site.link1',{url: '/link1,/newlink',... 解决方案 尝试在 url 中使用正则表达式和参数.这不是最佳的,但有效..state('site.link1',{url: '/{path:link1|newlink}',templateUrl: '/views/link1.html',控制器:'link1Ctrl'})更多信息网址中的正则表达式.要生成带有ui-sref的链接,将状态名称作为函数传递相同的参数<a ui-sref="site.link1({path:'link1'})" >站点链接 1</a><a ui-sref="site.link1({path:'newlink'})">站点新链接</a>I have a request to add in another URL parameter that directs to a state that I already have set up. For efficiency purposes, I'm trying to see if I can add multiple URLs to point to the same state, or should I just use the $UrlRouterProvider.when() method to re-direct to that state in this new case.Ex. this is what already exists.state('site.link1', { url: '/link1', templateUrl: '/views/link1.html', controller: 'link1Ctrl' })and the request is to add www.site.com/newlink that points to the link1 page. Is there something like this;.state('site.link1', { url: '/link1, /newlink', ... 解决方案 Try using the Regex and a parameter in the url. It is not optimal but works..state('site.link1', { url: '/{path:link1|newlink}', templateUrl: '/views/link1.html', controller: 'link1Ctrl' })More information on regex in Urls.To generate links with ui-sref pass the same parameter with the state name as a function <a ui-sref="site.link1({path:'link1'})" >site link 1</a><a ui-sref="site.link1({path:'newlink'})">site new link</a> 这篇关于AngularJs UI 路由器 - 具有多个 URL 的一种状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-20 20:13