I am trying to develop a website which has two completely different views for Desktop and Mobile. I achieved it by using different routing mechanism based upon device width. Here is an example.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
let routes : Routes = [];
if (window.innerWidth < 768) {
routes = [
{path: '', component: MobileComponent},
// ...
];
} else {
routes = [
{path: '', component: DesktopComponent},
// ...
];
}
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
But for SSR application, I am not supposed to use window variables. How can I achieve the same result along with SSR?