Angular 2 audio won't break by changing component

Viewed 2107

I want to play audio with help of this code and it works fine

  ngOnInit () {
    const a = new Audio();
    a.src = '../../assets/hello.wav';
    a.load();
    // auto-start
    a.play();
  }

But when I click Next Button, that leads me to next page ( so I change my component with help of routing) the audio will not stop (will not break) and the music from audio plays on the next page also. What should I add to my code to make it possible by changing page break the audio?

1 Answers
Related