title: angular 2 - how embed youtube video
body: <p>I got this code</p>
  
  <pre><code> &lt;div *ngIf="topic.video"&gt;
          &lt;div class="video-container"&gt;
              &lt;iframe width="300" height="169" src="topic.video.url" style="border:0"&gt;&lt;/iframe&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>problem: angular will output <code>src="localhost://8001"</code> instead of <code>src="https://www.youtube.com/embed/hr4BbdUiTUM"</code></p>
  
  <p>What could be wrong here?</p>
  
  <p>UPDATE 2</p>
  
  <p>This is what got after Gunter's answer.</p>
  
  <pre><code>import { Component, OnInit, Pipe, Sanitizer } from '@angular/core';
  import { DataService } from '../../shared/data';
  
      @Component({
          template: `
              &lt;div class="subheader"&gt;Feed&lt;/div&gt;
                  &lt;div *ngFor="let topic of topics; let index = index; trackBy: trackByFn"&gt;
                      &lt;div *ngIf="topic.type == 'discussion'"&gt;
                          &lt;div *ngIf="topic.video"&gt;
                              &lt;div class="video-container"&gt;
                                  &lt;iframe src="{{sanitizer.bypassSecurityTrustResourceUrl(topic.video.url)}}" &gt;&lt;/iframe&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          `
      })
      export class CompanyComponent implements OnInit {
          constructor(
              private sanitizer:Sanitizer,
              private dataService: DataService
          ) {}
  
          ngOnInit() {
              this.topics = this.dataService.topics;
          }
      }
  </code></pre>
  
  <p>I still got this error</p>
  
  <pre><code>company.ts?ac6a:121 Error: Uncaught (in promise): Error: Error in ./CompanyComponent class CompanyComponent - inline template:29:41 caused by: unsafe value used in a resource URL context (see http://g.co/ng/security#xss)
  Error: unsafe value used in a resource URL context (see 
  </code></pre>