title: How to translate "get element by id" into typescript
body: <p>My Project runs on Angular 8 with typescript.<br></p>
  
  <p>Im trying to get an html audio element by id and store it in a variable.
  Then i want to get the duration out of the Element and store it in another variable.</p>
  
  <p>As seen in a working example, in Javascript, this would go as: <br></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;audio id="music" preload="true"&gt;
    &lt;source src="./assets/img/hollywood.mp3"&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var music = document.getElementById('music'); 
  var duration = music.duration;
  </code></pre>
  
  <p>now my translation to typescript is this: <br></p>
  
  <p><strong>TS</strong></p>
  
  <pre><code>public music = &lt;HTMLAudioElement&gt;document.getElementById("music");
  public duration = this.music.duration;
  </code></pre>
  
  <p>But when i load the page, i get the error "Uncaught (in promise): TypeError: this.music is null"
  and i dont get why.</p>