Regex 在Angularjs UI路由器中,如何使用条件检查URL?
现在我的路线文件中有了这段代码Regex 在Angularjs UI路由器中,如何使用条件检查URL?,regex,url,numbers,integer,Regex,Url,Numbers,Integer,现在我的路线文件中有了这段代码 $stateProvider. state('home', { url: '/', templateUrl: 'modules/core/views/home.client.view.html' }). state('thread', { url: '/:thread_id', templateUrl: 'modules/core/views/thread.client.view.html' }). state('privacy',
$stateProvider.
state('home', {
url: '/',
templateUrl: 'modules/core/views/home.client.view.html'
}).
state('thread', {
url: '/:thread_id',
templateUrl: 'modules/core/views/thread.client.view.html'
}).
state('privacy', {
url: '/privacy',
templateUrl: 'modules/core/views/privacy.client.view.html'
}).
state('terms', {
url: '/privacy',
templateUrl: 'modules/core/views/terms.client.view.html'
});
我的目标是:当thread_id为纯整数时,它将导航到thread.client.view.html。否则,它会导航到其他页面,如隐私、条款等
这有可能实现吗?终于实现了
state('thread', {
url: '/{thread_id:[0-9]{0,100}}',
templateUrl: 'modules/core/views/thread.client.view.html'
}).
参考:Regex参数