Skip to content

Instantly share code, notes, and snippets.

@SpeedoPasanen
Created September 22, 2017 13:57
Show Gist options
  • Save SpeedoPasanen/68f4e08a2bb35d741c426f2eae3ea82c to your computer and use it in GitHub Desktop.
Save SpeedoPasanen/68f4e08a2bb35d741c426f2eae3ea82c to your computer and use it in GitHub Desktop.
FrameService
import { Injectable, EventEmitter } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Router } from '@angular/router';
@Injectable()
export class FrameService {
constructor(private router: Router) { }
public srcChange: Subject<string> = new Subject<string>();
public frameClosed: EventEmitter<any> = new EventEmitter<any>();
public set src(url: string) {
if (!url) {
this.router.navigate([], {});
this.frameClosed.emit(true); // Let interested components know database may've been updated.
return;
}
this.srcChange.next(url.replace(/^\//, ''));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment