Angular 5 Mat-grid list responsive

后端 未结 6 1694
灰色年华
灰色年华 2021-01-30 03:08

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

6条回答
  •  暖寄归人
    2021-01-30 03:47

    Addition to the @Leo Caserio' s answer, if you get an error on the first load as follows:

    Error: mat-grid-list: must pass in number of columns. Example: ...

    You can use subject:

    Component

    @ViewChild('grid',{static:true}) grid: MatGridList;
    cols:Subject = new Subject();
    
    constructor(private observableMedia: MediaObserver) { }
    
    ngAfterContentInit() {
        this.observableMedia.asObservable().subscribe((change: MediaChange[]) => {
          this.cols.next(this.gridByBreakpoint[change[0].mqAlias]);
        });
      }
    

    Template

    
    

    Note: @angular/flex-layout": {"version": "8.0.0-beta.26" }

提交回复
热议问题