File

libs/video-stat-dashboard/src/video-container/video-container-display.component.ts

Implements

OnChanges

Metadata

selector video-container-display
templateUrl ./video-container-display.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(sanitizer: DomSanitizer)
Parameters :
Name Type Optional
sanitizer DomSanitizer no

Inputs

currentVideo

Type: Video

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges no
Returns : void

Properties

currentVideoUrl
currentVideoUrl: SafeUrl
Type : SafeUrl
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';

import { Video } from '../+state/video-stats.interfaces';

const URLPREFIX = 'https://www.youtube.com/embed/';

@Component({
  selector: 'video-container-display',
  templateUrl: './video-container-display.component.html'
})
export class VideoContainerDisplayComponent implements OnChanges {

  @Input() currentVideo: Video;
  currentVideoUrl: SafeUrl;

  constructor(private sanitizer: DomSanitizer) { }

  ngOnChanges(changes: SimpleChanges) {
    // good use of ngOnChanges - wire data through, around default sanitization
    if (changes['currentVideo'] && changes['currentVideo'].currentValue) {
      const incomingVideo = changes['currentVideo'].currentValue as Video;
      this.currentVideoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(URLPREFIX + incomingVideo.id);
    }
  }
}
<div class="card">
  <div *ngIf="currentVideo" class="card-content">

    <div class="card-title">{{currentVideo.title}} - {{currentVideo.author}}</div>
    <div class="video-container">
      <iframe width="560" height="315" [src]="currentVideoUrl" frameborder="0" allowfullscreen></iframe>
    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""