/*-------------------------------------------------------------------------------------------------------------- * Copyright (c) insite-gmbh. All rights reserved. * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------------------------*/ import { Router, Event, NavigationStart } from '@angular/router'; export class RoutingDisabler { private _sub: any; constructor(private _router: Router) { this._sub = _router.events.subscribe(this.handleRouterEvent.bind(this)); } public reEnable() { this._sub.unsubscribe(); } private handleRouterEvent(ev: Event) { if (ev instanceof NavigationStart && ev.url !== this._router.url) { this._router.navigateByUrl(this._router.url); } } }