Alternative using angular / flex-layout package with
FxHide API and fxShow API
Example
<div fxShow fxHide.xs="false" fxHide.lg="true"> ... </div>
When activated breakpoint:
xl , then override the default fxShow; therefore div is displayedlg , then div is hidden (since value === 'true')md , then go back to the default fxShow file, so the div is displayedsm , then override the default fxShow; therefore div is displayedxs , then div is displayed (since value === 'false')
This is a bracketing list.

or using ObservableMedia
Example
import {MediaChange, ObservableMedia} from "@angular/flex-layout"; const PRINT_MOBILE = 'print and (max-width: 600px)'; @Component({ selector : 'responsive-component', template: ` <div class="ad-content" *ngIf="media.isActive('xs')"> Only shown if on mobile viewport sizes </div> ` }) export class MyDemo implements OnInit { constructor(public media: ObservableMedia) { } ngOnInit() { if (this.media.isActive('xs') && !this.media.isActive(PRINT_MOBILE)) { this.loadMobileContent(); } } loadMobileContent() { } }
- print and
(max-width: 600px) are mediaQuery for printing viewport sizes on mobile devices. xs is an alias associated with the size of the mediaQuery media portal.
marco gomes
source share