问题
On my ionic project, I have created side menu at app.html
to be available through the whole app, this menu contains items with links that should be opened externally. I have tried to open them with InAppBrowser but I have this error pups up:
uncaught (in promise) invalid views to insert
app.html:
<ion-list no-margin>
<ion-item menuClose ion-item no-lines *ngFor="let l of SocialLinks" (click)="openPage(l.Url)">
<ion-icon name="{{l.icon}}"></ion-icon>
</ion-item>
</ion-list>
app.component.ts:
import { InAppBrowser } from '@ionic-native/in-app-browser';
...
@Component({
templateUrl: 'app.html',
providers: [InAppBrowser]
})
...
constructor(
...
private iab: InAppBrowser
)
...
this.SocialLinks = [
{ title: 'twitter', Url: 'https://twitter.com', icon: 'logo-twitter' },
{ title: 'facebook', Url: 'https://facebook.com', icon: 'logo-facebook' },
{ title: 'instagram', Url: 'https://instagram.com', icon: 'logo-instagram' },
{ title: 'linkedin', Url: 'https://linkedin.com', icon: 'linkedin' },
];
...
OpenUrl(Url: string, myEvent) {
const browser = this.iab.create(Url);
browser.show();
}
is there any way to open those links from the side menu?
回答1:
Have you noticed that the method you call in the click
is not the same one you call when you show an Ionic Page
来源:https://stackoverflow.com/questions/52427032/ionic4-how-to-open-external-link-from-side-menu