K
K
Kan_A2018-11-08 09:31:00
Angular
Kan_A, 2018-11-08 09:31:00

How to make a mobile version of the site on Angular?

For a personal project, you need to implement a mobile version in Angular (m.site.com). But I don't have any experience in Angular development. Consider first job.
How to make a mobile version of the site on Angular?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2018-11-08
@Casufi

https://developer.mozilla.org/ru/docs/Web/CSS/Medi...
Works not only for angular.

K
Kan_A, 2018-11-08
@Kan_A

I thought about it and came to the obvious conclusion: I'm dumb

const maxMobileWidthPx = 600;
const isMobile = () => {
  return window.innerWidth <= maxMobileWidthPx;
}
const routes: Routes = [
  {
    path: '', pathMatch: 'full',
    redirectTo: isMobile() ? 'mobile' : 'desktop'
  },
  {
    path: 'desktop', component: DesktopComponent
  },
  {
    path: 'mobile', component: MobileComponent
  }
]

Practical or not, I don't know yet, but it works!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question