HI!
I am currently developing a pwa that runs as website for browsers and as app for mobiles. The challenge is that the browser design has elements that differ form the mobile apps, like different header and more funcionalities. I want to use the same code on both.
For now i’m checking the running platform and using different templates. But i think there must be a better way.
Can anyone give me some advice about the best way to implment this?
Which version of Ionic are you using? Ionic 3, right?
In my opinion if the templates for desktop vs mobile only have a few specific differences, you can use ngIf, ngHide and/or ngSwitch to show/hide the differentiating components.
In any case I’d expect that Ionic, as a PWA framework, provides an easy (automatic) way to handle this kind of situation.
There are some old posts related to this topic, like:
I Still haven’t found a good solution for this.
I’m already using responsive design when possible, (for example in grid elements to resize the number of columns) and also I am using ngIf when the changes don’t differ a lot. I still feeling forced to use ngTemplates when the views are different.
I hope there is a better solution for this. It would be nice to be able to define different selectors and views for different cases.
With this lib you can add several checks for different screen sizes or devices or browser or many others.
Another big advantage I figured out, showWhen and hideWhen only add display: none to element, but in fact the component is still there. I think this lib is more then an *ngIf, so it is not rendered and so not in the DOM present!
This could be a very big advantage.
It would be very very nice to see something like that in ionic in feature!