1 possible answer(s) on “Modal stays open when clicking the back button

  1. Just for reference. Here is a way to close the modal when the back button is clicked.

    import { PlatformLocation } from '@angular/common';
    
    ...
    
      constructor(
        private modalService: NgbModal,
        private location: PlatformLocation
      ) {
        // closes modal when back button is clicked
        location.onPopState(() => this.close());
      }