I have built part of my app to display local PDFs from a pdf folder under assets in an iframe. It works fine in ionic lab, but will it work with ios and android native?
Is there anything special I need to do?
html
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="/"></ion-back-button>
</ion-buttons>
<ion-title>{{information.name}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<iframe name= "eventsPage" [src]="this.mysite" width="100%" height="95%">
</iframe>
</ion-content>
ts
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {GetProtocolsService} from '../../services/get-protocols.service';
import { DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'app-protocol-details',
templateUrl: './protocol-details.page.html',
styleUrls: ['./protocol-details.page.scss'],
})
export class ProtocolDetailsPage implements OnInit {
information = null;
protocols = null;
mysite = null;
constructor(private activatedRoute: ActivatedRoute, private protocolService: GetProtocolsService, private router: Router,
private sanitizer: DomSanitizer) { }
ngOnInit() {
// Get the ID that was passed with the URL
let id = this.activatedRoute.snapshot.paramMap.get('id');
console.log('Details');
this.protocolService.getProtocols().subscribe(result => {
console.log('getHospitals1 executed')
this.protocols = result;
console.log('result', result);
this.information = this.filterArr(id)[0];
console.log('information', this.information);
this.mysite = this.sanitizer.bypassSecurityTrustResourceUrl('../../../assets/pdf/' + this.information.pdf.toString());
});
}
filterArr(search) {
// Get the real array forst of all
let arr = this.protocols;
return arr.filter(oneObj => oneObj.id.indexOf(search) >= 0);
}
}