I'm trying to load external website in a div using jquery in ionic 3.
TS:
export class HomePage
{
constructor(public navCtrl: NavController) {
$('#loadExternalURL').load('http://www.google.com');
}
}
HTML:
<ion-content>
<div id="loadExternalURL"></div>
</ion-content>
I'm getting blank screen on serving the ionic app. Is there anything I'm missing? Any Suggestion?
To use jQuery in ionic project do it this way:
Install the Jquery module in your IONIC-3 app as follows:
then import jquery on your page like this
You can then use the jquery $ as you would in normal javascript. I have used it for a jquery ajax call to get remote data like this:
It worked very fine.
I did it in following way,
Install Jquery module in your IONIC-3 app,
npm install jquery --save
Import JQuery in HomePage.ts
import * as $ from "jquery";
Use $ to call jquery methods.
I wait for method ngAfterViewInit to make sure view is initialized.
You not need to use jQuery
You can add iframe
You need to import jQuery into your project somehow. If you want to use HTML you need to add it near the top of your page
Or use a .d.ts file defining jQuery
then define it where needed
References used:
TypeScript and libraries such as jQuery (with .d.ts files)
How do I get jQuery autocompletion in TypeScript?