Error in MediaQuery in Angular 7 and Flex-Layout

0

I'm moving an Angular project from version 6 to version 7, and I find an error when compiling:

  

ERROR in src / app / options / services / media-query.service.ts: error   TS2322: Type 'MediaQueryListEvent' is not assignable to type   'MediaQueryList'.

I'm using Flex-layout and update it in the package.json like this:

"@angular/flex-layout": "^7.0.0-beta.19"

But it seems that something else changed because in version 6 this worked very well.

This is the service code 'media-query.service.ts':

import { MediaMatcher } from '@angular/cdk/layout';

const LIMITE_ANCHO_MENU = 750;
const LIMITE_ANCHO_TITULO = 375;

export class MediaQueryService {
  private matcher: MediaQueryList;

  constructor(private zone: NgZone,             
              private mediaMatcher: MediaMatcher) {

    this.matcher = this.mediaMatcher.matchMedia('(max-width: ${LIMITE_ANCHO_MENU}px)');

    this.matcher.addListener(mql => this.zone.run(() => {
      this.matcher = mql;      
    }));
}

The error appears on the line where I have the instruction: this.matcher = mql;

A thousand thanks for the help.

    
asked by Diana 14.11.2018 в 06:17
source

0 answers