Skip to content

Instantly share code, notes, and snippets.

@eoz
eoz / angular2-if-media-query-directive.ts
Created March 29, 2017 12:54 — forked from davidmarquis/angular2-if-media-query-directive.ts
Angular 2: Conditional output from media query using a structural directive
import { Directive, TemplateRef, ViewContainerRef } from "@angular/core";
import { isBlank } from "@angular/core/src/facade/lang";
/**
* How to use this directive?
*
* ```
* <div *ngIfMediaQuery="'(min-width: 500px)'">
* Div element will exist only when media query matches, and created/destroyed when the viewport size changes.