import { Injectable } from '@angular/core';
import { Protocol } from '../utils/types';
function _window(): any {
// return the global native browser window object
return window;
}
@Injectable()
export class WindowRef {
get nativeWindow(): any {
return _window();
}
openExternalHttpTab(path: string): void {
this.navigateToUrl('http', path, true);
}
navigateToUrl(protocol: Protocol, path: string, newTab: boolean) {
let params = [`${protocol}://${path}`], window = this.nativeWindow;
Eif (newTab) params.push('_blank');
window.open.apply(window, params);
}
}
|