I would like to implement an application with multiple components and modules using Angular Material for desktop and Ionic for mobile. So far, the solution I found is to create two different lazy modules and config the routes based on window-sized.
For example, in order to create a page, I should create a component in the mobile module and a similar one in the desktop module. As you can guess, the logic of my component is copied into two seperate ts
files while it should be in one ts
file. As the application grows, the maintenance of the project will be harder and harder.
Question
How can I have only one ts file for each component and inject the suitable HTML (or probably CSS) based on window size? It is very important to make both views lazy loaded, so when a user reaches the site via mobile will not download the desktop view.
Desirable result as something like this:
@Component({
selector: 'app-example',
templateUrl: isMobile == true ? './desktop.html' : './mobile.html',
})