【发布时间】:2020-03-05 15:16:31
【问题描述】:
我想在使用 InAppBrowser 启动 ionic 时输出一个浏览器,但是输出一个错误并且显示屏幕上没有任何内容显示为白页。 为什么?
app.module.ts:
import { InAppBrowser} from '@ionic-native/in-app-browser/ngx'; //add
@NgModule({
(ellipsis)
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
InAppBrowser // add
],
bootstrap: [AppComponent]
})
export class AppModule {}
home.page.ts
import { Component, OnInit} from '@angular/core';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; // add
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
constructor(private inAppBrowser: InAppBrowser) {} // add
ngOnInit() {
const browser = this.inAppBrowser.create('https://www.google.com', '_blank', { location: 'no', zoom: 'no'});
}
}
错误:
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[HomePage -> InAppBrowser]:
StaticInjectorError(Platform: core)[HomePage -> InAppBrowser]:
NullInjectorError: No provider for InAppBrowser!
NullInjectorError: StaticInjectorError(AppModule)[HomePage -> InAppBrowser]:
StaticInjectorError(Platform: core)[HomePage -> InAppBrowser]:
NullInjectorError: No provider for InAppBrowser!
(ellipsis)
【问题讨论】:
标签: angular typescript ionic-framework ionic4