Cam*_*ron 10 javascript angularjs angular-ui-router
我使用AngularJS和UI的路由器和我app.js.我有以下几行:
$urlRouterProvider.otherwise('/');
Run Code Online (Sandbox Code Playgroud)
但是,我不希望它将用户发送到URL,而是 发送到以下状态:
.state('404',
{
views: {
'body': {
templateUrl: 'partials/404.html',
}
}
});
Run Code Online (Sandbox Code Playgroud)
通常我会这样做:
$state.go('404');
Run Code Online (Sandbox Code Playgroud)
如何为其他方法执行此操作?
注意:我的404状态没有URL,因此基本上它保留了用户输入或访问的URL,只是更改了模板.
小智 24
我想你用这段代码实现了这一点
$urlRouterProvider.otherwise(function($injector, $location){
$injector.invoke(['$state', function($state) {
$state.go('404');
}]);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4848 次 |
| 最近记录: |