Reputation: 668
I am using ionic 1 and i want to load an external url inside ion-content (like the Messenger app does) i have already tried cordova-plugin-inappbrowser but it loads the url in a new page.
This is the code i've used:
cordova.InAppBrowser.open(item.url, '_self');
I also tried embedding the url inside iframe but it refused to display since the url is not not mine.
This is what i wrote <iframe src="{{item.url | trustUrl}}"></iframe>
any help will be appreciated :)
Upvotes: 4
Views: 9554
Reputation: 650
I tried it with i frame and domsanitizer My Html is
<ion-header>
<ion-navbar color="danger">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Payments Detail</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<iframe width="100%" height="100%" [src]="myurl" frameborder="0" allowfullscreen></iframe>
</ion-content>
and my ts is
import { Component } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import {DATA} from "../../app/config";
import {NavParams, ToastController} from "ionic-angular";
import {Network} from "@ionic-native/network";
@Component({
templateUrl: 'paymentDetail.html'
})
export class PaymentDetail {
myurl:any="";
constructor(private network: Network,private toastCtrl: ToastController,private sanitizer: DomSanitizer,public navParams: NavParams) {
}
ngOnInit() {
if(this.network.type !="none"){
console.log(this.navParams.get("payment"));
this.myurl=this.sanitizer.bypassSecurityTrustResourceUrl(DATA["API_BASE_URL2"]+"userpage/RedirectNow?id="+this.navParams.get("payment"));
}else {
let toast = this.toastCtrl.create({
message: "check your internet connection before process",
duration: 2000,
position: 'middle'
});
toast.present();
}
}
}
Try this .
Upvotes: 7