IMPORTANT!
This forum is now archived. Click here for the New Support Forum
mobileQuery.addEventListener
Quote from CHRIS on September 4, 2020, 8:16 pmHi working with the Pro w angular 9.1.3 and mobile device with chrome browser and continue to receive Error: this.mobileQuery.addEventListener is not a function from my research it appears it should not be called until after the html is loaded not in constructor. I moved it in app.component to NgInit and still receive errors. hope someone has seen this before ..
Hi working with the Pro w angular 9.1.3 and mobile device with chrome browser and continue to receive Error: this.mobileQuery.addEventListener is not a function from my research it appears it should not be called until after the html is loaded not in constructor. I moved it in app.component to NgInit and still receive errors. hope someone has seen this before ..
Quote from Ingo on September 6, 2020, 1:18 pmHI,
Try calling this in ngAfterViewInit. Unfortunately, I cannot understand the error with me.
HI,
Try calling this in ngAfterViewInit. Unfortunately, I cannot understand the error with me.
Quote from CHRIS on September 8, 2020, 1:37 pm.. moved the function call to addEventListener() into ngAfterViewInit() with the same result. It was initially in the constructor and moved into ngOnInit . Please see image attached.
.. moved the function call to addEventListener() into ngAfterViewInit() with the same result. It was initially in the constructor and moved into ngOnInit . Please see image attached.
Quote from CHRIS on September 8, 2020, 2:25 pmsolved.. although addListener is deprecated it works fine in Chrome iOS latest. removeEventListener has no issues ..
solved.. although addListener is deprecated it works fine in Chrome iOS latest. removeEventListener has no issues ..
Quote from CHRIS on September 9, 2020, 7:05 pmapp.component.ts
constructor(
storageManager: LocalStoreManager,
private toastaService: ToastaService,
private toastaConfig: ToastaConfig,
private accountService: AccountService,
private alertService: AlertService,
private notificationService: NotificationService,
private appTitleService: AppTitleService,
private authService: AuthService,
private translationService: AppTranslationService,
private matIconRegistry: MatIconRegistry,
private domSanitizer: DomSanitizer,
public configurations: ConfigurationService,
public router: Router,
public dialog: MatDialog,
changeDetectorRef: ChangeDetectorRef,
media: MediaMatcher) {this.matIconRegistry.addSvgIconSet(this.domSanitizer.bypassSecurityTrustResourceUrl('../assets/custom-icons.svg'));
this.mobileQuery = media.matchMedia('(max-width: 600px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();storageManager.initialiseStorageSyncListener();
this.toastaConfig.theme = 'material';
this.toastaConfig.position = 'top-right';
this.toastaConfig.limit = 100;
this.toastaConfig.showClose = true;
this.toastaConfig.showDuration = false;
//this.mobileQuery.addEventListener('change', this._mobileQueryListener <= note the replacement to deprecated .addListener
this.mobileQuery.addListener( this._mobileQueryListener);
this.appTitleService.appName = this.appTitle;
}
app.component.ts
constructor(
storageManager: LocalStoreManager,
private toastaService: ToastaService,
private toastaConfig: ToastaConfig,
private accountService: AccountService,
private alertService: AlertService,
private notificationService: NotificationService,
private appTitleService: AppTitleService,
private authService: AuthService,
private translationService: AppTranslationService,
private matIconRegistry: MatIconRegistry,
private domSanitizer: DomSanitizer,
public configurations: ConfigurationService,
public router: Router,
public dialog: MatDialog,
changeDetectorRef: ChangeDetectorRef,
media: MediaMatcher) {
this.matIconRegistry.addSvgIconSet(this.domSanitizer.bypassSecurityTrustResourceUrl('../assets/custom-icons.svg'));
this.mobileQuery = media.matchMedia('(max-width: 600px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
storageManager.initialiseStorageSyncListener();
this.toastaConfig.theme = 'material';
this.toastaConfig.position = 'top-right';
this.toastaConfig.limit = 100;
this.toastaConfig.showClose = true;
this.toastaConfig.showDuration = false;
//this.mobileQuery.addEventListener('change', this._mobileQueryListener <= note the replacement to deprecated .addListener
this.mobileQuery.addListener( this._mobileQueryListener);
this.appTitleService.appName = this.appTitle;
}
IMPORTANT!
This forum is now archived. Click here for the New Support Forum