Reputation: 43
I am currently porting my project to Ionic 4 and wanted to replace the Cordova InAppBrowser with the Capacitor browser but with little success so far... This is my page:
import { Component, OnInit } from '@angular/core';
import {Plugins} from '@capacitor/core';
const { Browser } = Plugins;
@Component({
selector: 'app-srd',
templateUrl: './srd.page.html',
styleUrls: ['./srd.page.scss'],
})
export class SrdPage implements OnInit {
constructor() {
}
async ngOnInit() {
const url = 'http://capacitor.ionicframework.com/';
await Browser.open({'url': url});
}
}
There is no console output and the page stays blank. Any ideas what went wrong?
Upvotes: 1
Views: 8867
Reputation: 211
import { Browser } from '@capacitor/browser';
async openLink(Url){
await Browser.open({ url: Url });
}
Upvotes: 0
Reputation: 119
const url = 'http://capacitor.ionicframework.com/';
await Browser.open({url: url});
Upvotes: -1
Reputation: 166
This should work. Remove the quote around the first url:
import { Component, OnInit } from '@angular/core';
import {Plugins} from '@capacitor/core';
const { Browser } = Plugins;
@Component({
selector: 'app-srd',
templateUrl: './srd.page.html',
styleUrls: ['./srd.page.scss'],
})
export class SrdPage implements OnInit {
constructor() {
}
async ngOnInit() {
const url = 'http://capacitor.ionicframework.com/';
await Browser.open({'url': url});
}
}
Upvotes: 3