Skip to content

Instantly share code, notes, and snippets.

@Kukks
Last active May 24, 2016 14:56
Show Gist options
  • Save Kukks/9ea882e33471784ce2a12c5ddc1baa23 to your computer and use it in GitHub Desktop.
Save Kukks/9ea882e33471784ce2a12c5ddc1baa23 to your computer and use it in GitHub Desktop.
import { autoinject } from "aurelia-dependency-injection";
import { Router } from "aurelia-router";
import { ObserverLocator } from "aurelia-binding";
declare var $: any;
@autoinject()
export class ModalService {
constructor( private router: Router, private observerLocator: ObserverLocator ) {
this.observeRouterNavigation();
}
public closeModal() {
$(".lean-overlay").trigger("click");
}
private observeRouterNavigation() {
this.observerLocator
.getObserver(this.router, "isNavigating")
.subscribe(( newValue: boolean, oldValue: boolean ) => {
if ( !newValue ) {
this.closeModal();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment