1// Route guards would be a good solution for this purpose.
2
3// The MobileGuard would look like this :
4
5export class MobileGuard implements CanActivate {
6 constructor(private _router: Router, private _mobileService: MobileService) {}
7
8 canActivate(): boolean {
9 const isMobile = this._mobileService.isMobile();
10 if(!isMobile) {
11 this._router.navigate(['/desktop']);
12 }
13 return isMobile;
14 }
15}
16// The same for the DesktopGuard.
17
18// The user trying to access any of the routes, would be redirected to the right one.
19
20