izu*_*pet 15 javascript resolve typescript angular2-routing angular
尝试访问不允许的页面时,我尝试将用户导航到错误页面.问题是skipLocationChange在这种情况下不起作用.它导航到错误页面,但URL更改为根.如何保持原始网址用户?
resolve(route: ActivatedRouteSnapshot): Observable<any|boolean>|boolean {
return this.apiclientService.get('cars/' + route.params['id']).map(
response => {
if (response.data.user_id === this.authService.user().id) {
return response.data;
}
this.router.navigate(['/404'], { skipLocationChange: true });
return false;
}
).catch(error => {
this.router.navigate(['/404'], { skipLocationChange: true });
return Observable.of(false);
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1484 次 |
| 最近记录: |