与表单交互时,iframe会自动刷新 - Ionic2 / Firebase

时间:2017-08-18 19:21:31

标签: angular firebase ionic2

我正在创建一个简单的消息传递应用,它使用iframe嵌入多个Spotify小部件。该歌曲的网址存储在firebase中,需要进行编码和编辑。在展示前消毒。当我与表单交互时,所有小部件都会刷新。有没有办法阻止这种刷新?我认为使用函数获取已清理的URL是一个问题,但我不知道如何修复。

constructor(public navCtrl: NavController, public navParams: NavParams, af: AngularFire, messageData: MessageProvider,
              public channelProvider: ChannelProvider, public spotifyProvider: SpotifyProvider, public authProvider: AuthProvider,
              public messageProvider: MessageProvider, public sanitizer: DomSanitizer, private formBuilder: FormBuilder) {
    this.channel = navParams.data.channel || {$key: 1};
    this.items = af.database.list('/channels/' + this.channel.$key);
    this.items.subscribe(x => {
      this.content && this.content.scrollToBottom(0)
    });
    this.messageForm = this.formBuilder.group({
      message: ['', Validators.required],
    });
  }

  encodeURI(uri) {
    let url = `https://embed.spotify.com/?uri=${encodeURIComponent(uri)}`;
    return this.sanitizer.bypassSecurityTrustResourceUrl(url);
  }
<ion-row *ngIf="item.detail?.spotifyUri" class="spotifyPlayer">
   <iframe [src]='encodeURI(item.detail.spotifyUri)' width="100%" height="380" frameborder="0" allowtransparency="true"></iframe>
</ion-row>

0 个答案:

没有答案