1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular 7 iframe history back button trouble

Discussão em 'Angular' iniciado por Forno96, Outubro 17, 2024 às 03:42.

  1. Forno96

    Forno96 Guest

    I'm developing a SPA using angular. When the history back button is pressed, the browser changes only the Youtube iframe and not the entire page, I need to press 2 times the back button to go in the full previous page (at the first time the URL is not updated). This happens only when following 2 links with the same route involving the YT iframe element. I need to keep history navigation, so I can't only delete history elements

    Component
    export class PlayerComponent implements OnInit {
    videoName: string;
    videoUrl: any;

    constructor(
    private sanitizer: DomSanitizer,
    private route: ActivatedRoute
    ) {}

    ngOnInit() {
    this.route.params.subscribe( params => {
    this.videoUrl = this.sanitizer.bypassSecurityTrustResourceUrl('https://www.youtube.com/embed/' + params.videoId);
    });
    }
    }

    HTML
    <div class="embed-responsive embed-responsive-16by9">
    <iframe class="embed-responsive-item border border-primary" *ngIf="videoUrl"
    [src] = "videoUrl"
    allowfullscreen>
    </iframe>
    </div>

    Continue reading...

Compartilhe esta Página