Jed*_*Jed 4 angularjs angular-ui-router
根据文档,angularjs ui-router url参数默认是可选的.那么有没有办法创建强制参数?就像参数丢失或为null时,它不会进入页面?
希望您能够帮助我.
谢谢
使用UI路由器解析以检查路由参数是否丢失.
//Example of a single route
.state('dashboard', {
url: '/dashboard/:userId',
templateUrl: 'dashboard.html',
controller: 'DashboardController',
resolve: function($stateParams, $location){
//Check if url parameter is missing.
if ($stateParams.userId === undefined) {
//Do something such as navigating to a different page.
$location.path('/somewhere/else');
}
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2162 次 |
| 最近记录: |