Created
September 22, 2017 13:57
-
-
Save SpeedoPasanen/68f4e08a2bb35d741c426f2eae3ea82c to your computer and use it in GitHub Desktop.
FrameService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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