import {Directive, Input, OnInit} from "@angular/core"; import {MatSelect} from "@angular/material/select"; @Directive({ selector: '[modal-select]' }) export class ModalSelectDirective implements OnInit{ @Input() matSelect: MatSelect; ngOnInit() { this.matSelect._openedStream.subscribe( () => { let divElement: HTMLDivElement = document.getElementsByClassName('cdk-overlay-container')[0]; divElement.classList.add('modal-select'); }); } }