angularjs ui 路由器正则表达式
angularjs ui router regex
我正在尝试匹配 1 个可以有 2 种值的参数:'current' 或至少有 10 个密码的数字。
我试过:
url: '/history/{code:^current$|^[0-9]{10,}$}'
当我使用这个正则表达式时,我的应用程序会转到 history/current
,但是当我重新加载页面时,它会返回到 default.
任何人都可以帮助我说出我做错了什么或者我该如何调试吗?
有a working example。状态定义为:
.state('history', {
//url: '/history/{code:^current$|^[0-9]{10,}$}',
url: "/history/{code:current|[0-9]{10,}}",
templateUrl: 'tpl.html',
})
这些链接应该符合我们的预期:
Working:
<a href="#/history/current">history/current</a>
<a href="#/history/0123456789">history/0123456789</a>
<a href="#/history/1234567890123">history/1234567890123</a>
Will FAIL and fall to default:
<a href="#/history/other">history/other</a>
<a href="#/history/012345678">history/012345678</a> - 9 digits
<a href="#/history/123456789a">history/123456789a</a> - a at the end
检查一下here
我正在尝试匹配 1 个可以有 2 种值的参数:'current' 或至少有 10 个密码的数字。
我试过:
url: '/history/{code:^current$|^[0-9]{10,}$}'
当我使用这个正则表达式时,我的应用程序会转到 history/current
,但是当我重新加载页面时,它会返回到 default.
任何人都可以帮助我说出我做错了什么或者我该如何调试吗?
有a working example。状态定义为:
.state('history', {
//url: '/history/{code:^current$|^[0-9]{10,}$}',
url: "/history/{code:current|[0-9]{10,}}",
templateUrl: 'tpl.html',
})
这些链接应该符合我们的预期:
Working:
<a href="#/history/current">history/current</a>
<a href="#/history/0123456789">history/0123456789</a>
<a href="#/history/1234567890123">history/1234567890123</a>
Will FAIL and fall to default:
<a href="#/history/other">history/other</a>
<a href="#/history/012345678">history/012345678</a> - 9 digits
<a href="#/history/123456789a">history/123456789a</a> - a at the end
检查一下here