1 |
50169
|
argiro.kok
|
import {Component, ElementRef, Input} from '@angular/core';
|
2 |
|
|
import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
|
3 |
|
|
//Usage :: <i-frame [url]="url" width="30%" height="250"></i-frame>`
|
4 |
|
|
@Component({
|
5 |
|
|
selector: 'i-frame',
|
6 |
|
|
template: `
|
7 |
58598
|
k.triantaf
|
<div *ngIf="!style" class="iframeContainer uk-height-large">
|
8 |
|
|
<iframe [src]="safeUrl"></iframe>
|
9 |
57016
|
argiro.kok
|
</div>
|
10 |
58598
|
k.triantaf
|
<div *ngIf="style" class="iframeContainer" [ngStyle]="style">
|
11 |
|
|
<iframe [src]="safeUrl"></iframe>
|
12 |
|
|
</div>
|
13 |
50169
|
argiro.kok
|
`
|
14 |
|
|
})
|
15 |
|
|
export class IFrameComponent {
|
16 |
|
|
public safeUrl: SafeResourceUrl;
|
17 |
|
|
@Input() url ;
|
18 |
58598
|
k.triantaf
|
@Input() width: number;
|
19 |
|
|
@Input() height: number;
|
20 |
|
|
public style: any;
|
21 |
|
|
|
22 |
50169
|
argiro.kok
|
constructor(private sanitizer: DomSanitizer) {
|
23 |
|
|
}
|
24 |
|
|
ngOnInit() {
|
25 |
|
|
this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
|
26 |
58598
|
k.triantaf
|
if(this.width && this.height) {
|
27 |
|
|
this.style = {
|
28 |
|
|
"width.px": this.width,
|
29 |
|
|
"height.px": this.height
|
30 |
58874
|
konstantin
|
};
|
31 |
|
|
} else if(this.height) {
|
32 |
|
|
this.style = {
|
33 |
|
|
"height.px": this.height
|
34 |
|
|
};
|
35 |
58598
|
k.triantaf
|
}
|
36 |
50169
|
argiro.kok
|
}
|
37 |
|
|
}
|