【发布时间】:2021-07-15 20:56:45
【问题描述】:
我正在将应用浏览器添加到 Angular 离子项目中。我创建了一个标签项目。 在选项卡 1 中,我显示了我们单击的按钮,并且必须在网络上打开一个新页面。 这是 tab1.page.html 的代码
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Tab 1
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Tab 1</ion-title>
</ion-toolbar>
</ion-header>
<ion-button click="open()">Click here!</ion-button> <--------error here
<app-explore-container name="Tab 1 page"></app-explore-container>
</ion-content>
tab1.module.ts 的代码在这里
import { IonicModule } from '@ionic/angular';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Tab1Page } from './tab1.page';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { Tab1PageRoutingModule } from './tab1-routing.module';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
ExploreContainerComponentModule,
Tab1PageRoutingModule
],
declarations: [Tab1Page]
})
export class Tab1PageModule {
constructor(private iab: InAppBrowser) {}
open(){
const browser = this.iab.create('https://ionicframework.com/');
browser.on('loadstart').subscribe(event => {
});
browser.on('exit').subscribe(event => {
browser.close();
});
}
}
我只想打开单击按钮时提供的链接,但它不起作用
【问题讨论】: