In the application i am developing, it needs entirely two different views for Desktop and Mobile. Not possible using CSS as content is entirely different.
What I have done?
I had checked whether it is Desktop/Mobile in Routing file using code const isMobile = window.innerWidth < 768;
And in path component: component: isMobile ? MobileComponent : DesktopComponent
This is working perfectly in development environment. But while production build this fails ng serve --prod (obviously Angular 5)
Issue:
No errors at all, According to isMobile true/false it should load MobileComponent/ DesktopComponent. But it does not load even if isMobile is true/false
Always loads MobileComponent in both Desktop & Mobile. while isMobile value is getting calculated correctly, true for Mobile and false for Desktop
I think the reason is the routes are getting compile already before sending to client.
Workaround tried but not working:
Used a if..else condition, while calculating isMobile and giving that variable (component) instead of ternary operation in Routing file
Any way:
Is there any way I can use to achieve the same functionality?
Thanks in advance
 
     
     
     
     
     
    