订阅活动不止一次,虽然只按一次

时间:2018-06-14 08:20:44

标签: angular ionic2

有时当我点击我的应用程序中的链接时,我会打开同一个链接的几个标签,虽然我只在链接上按了一次。 它并不总是发生。

this.events.subscribe('placemark:selected', (placemark) => {

    console.log('placemark selected:', placemark);

    if(placemark==null){
      this.fileURL=null;
      return;
    }

    if (placemark.file != null) {

      console.log("pm file: ",placemark.file);
      let videoRegexp = new RegExp('.mp4', 'i');

      let pdfRegexp = new RegExp('.pdf', 'i');
      this.showPDF = pdfRegexp.test(placemark.file);

      if(videoRegexp.test(placemark.file)){  //in case the file is a video , use videojs for streaming
        let movId = placemark.file.substring(placemark.file.indexOf("?"));
        console.log(movId);
        this.fileURL =AppConfig.API_ENDPOINT +"ResourceServlet/template.html"+ movId;
        return;
      } else {           

        if(placemark.file.match((/\.(jpeg|jpg|gif|png)\?/))==null && !this.showPDF){

          let target = "_system";
          var browser = this.iab.create(placemark.file, target, this.options);

          browser.on('exit').subscribe(event=>{
            console.log("EXITTT");
            browser.close();
          }); 

          this.fileURL=null;
        } else {

          this.fileURL = placemark.file;
        }
      }

      this.PDF_VIEWER =this.pdf_viewer_host+"?file="+encodeURIComponent(this.fileURL+"&session="+sessionStorage.getItem('auth_item'));
      console.log("showPDF: ",this.showPDF )
    } else {

      //console.log("Corrupted URL");
      this.err.showError("URL Error","CorruptedURLError");
    }
});

0 个答案:

没有答案