i created grid list with column 6 and i want to be grid title take 100% width on small screen devices. Now it creates 6 column on small screens as well
Expected: One gri
I liked Altus answer, but I would like to have more breakpoints. So I've created a simple method with some breakpoints using FlexLayout ObservableMedia service instead of onResize:
import { AfterContentInit, Component, ViewChild } from '@angular/core';
import { MediaChange, ObservableMedia } from '@angular/flex-layout';
import { MatGridList } from '@angular/material';
@Component({
selector: 'app-grid',
templateUrl: './grid.component.html',
styleUrls: ['./grid.component.css']
})
export class GridComponent implements AfterContentInit {
@ViewChild('grid') grid: MatGridList;
gridByBreakpoint = {
xl: 8,
lg: 6,
md: 4,
sm: 2,
xs: 1
}
constructor(private observableMedia: ObservableMedia) {}
ngAfterContentInit() {
this.observableMedia.asObservable().subscribe((change: MediaChange) => {
this.grid.cols = this.gridByBreakpoint[change.mqAlias];
});
}
}
Breakpoint: {{grid.cols}}
1
2
3
4
5
6
7
8
See https://stackblitz.com/edit/angular-responsive-material-grid-leocaseiro