If you want to react on certain breakpoints (e.g. do something if width is less than 768px), you can also use BreakpointObserver:
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
{ ... }
const isSmallScreen = breakpointObserver.isMatched('(max-width: 599px)');
or even listen to changes to that breakpoint:
breakpointObserver.observe([
'(max-width: 768px)'
]).subscribe(result => {
if (result.matches) {
doSomething();
} else {
// if necessary:
doSomethingElse();
}
});