【问题标题】:How to fetch url from backend to iframe when change in selection in angular material更改角度材料中的选择时如何从后端获取url到iframe
【发布时间】:2020-06-14 01:23:27
【问题描述】:

.html 页面

<iframe width="100%" height="100%" src="{{url}}" frameborder="0" allowfullscreen></iframe>

.ts 文件

 this.url = 'https://www.youtube.com';

根据 url ifrmae src 从下拉列表中更改选择时应该更新。

【问题讨论】:

    标签: typescript angular-material angular-material-8


    【解决方案1】:

    在 .html 页面中

    <iframe width="100%" class="embed-responsive-item" height="100%" src="" frameborder="0" allowfullscreen></iframe>
    

    在 .ts 文件中

    import ElementRef from '@angular/core';
    

    在构造函数中初始化如下

    constructor(private hostElement: ElementRef)
    

    将这些行添加到您想要触发的任何位置。

    const iframe = this.hostElement.nativeElement.querySelector('iframe');
    iframe.src = 'https://www.youtube.com';
    

    【讨论】:

      猜你喜欢
      • 2018-12-08
      • 2018-11-06
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 2022-11-28
      相关资源
      最近更新 更多