hi every one , i have a problem
When you open a this page the settimeout function run to add the points to watch After 60 seconds,
i dont know why the PDF will be reloaded again, what is the problem?
<ion-content padding>
<iframe [src]='photoURL()' width="100%" height="100%" frameborder="0">
</iframe>
</ion-content>
import {Component,ViewChild} from '@angular/core';
import { Events,Platform,NavController,NavParams,AlertController,App,Slides} from 'ionic-angular';
import { Users } from './../../providers/users';//
import { DomSanitizer} from '@angular/platform-browser';
import {TranslateService} from '@ngx-translate/core';
import { AppUtilFunctions } from './../../app/appglobal/app.utilfuns';//
@Component({
selector: 'page-pdf-viewer',
templateUrl: 'pdf-viewer.html',
})
export class PdfViewerPage {
link :any;
title:any;
publication_id:any
user_id:any
timeOut:any;
constructor(public navCtrl: NavController,
private appUtils: AppUtilFunctions,
public navParams: NavParams,
private translateService: TranslateService,
private sanitizer: DomSanitizer,
private userpage: Users ) {
this.timeOut = setTimeout(() => this.addPoints(), 10000);
console.log(this.timeOut);
}
ionViewDidLoad() {
this.link = this.navParams.get("link");
this.title = this.navParams.get("title");
this.publication_id = this.navParams.get("publication_id");
this.user_id = this.navParams.get("user_id");
console.log( this.link,'this.link');
}
photoURL(){
return this.sanitizer.bypassSecurityTrustResourceUrl(this.link);
}
addPoints(){
if(this.user_id ){
let getPublication={publication_id:this.publication_id,user_id:this.user_id};
this.userpage.addPoints(getPublication)
.subscribe((res) => {
if (res.data=="success") {
// console.log('video ended successsfuuulllly and we add points');
}
else if (res.errors =='Error'){
// console.log('video ended successsfuuulllly but there is error when we add points')
}
},err => {
this.translateService.get('CheckConnection').subscribe(
value => {
// value is our translated string
this.appUtils.AppToast(value);
})
//alert('err')
if (err.error instanceof Error) {
// alert('client side error');
} else {
// alert('server side error');
}
})
}
}
ionViewDidLeave() {
//Stop refresh
clearTimeout(this.timeOut);
}
}
providers here
addPoints(Da){
let data = JSON.stringify(Object.assign(Da));
return this.http.post(this.api.API_URL+'points.php?action=addPoints', data).map(res=>res.json());
}