Gab*_*ary 2 typescript ionic2 angular
当我列出插件 ( cordova plugin list) 时,它会列在那里,但是当我在 android 设备上运行我的代码时,我在控制台中收到此消息(来自 chrome 远程调试器):
Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open, all instance methods will NOT work.
我有最新版本的 ionic-cli。
我在这里包含了一个示例项目:https : //github.com/golear91/ionic2-broken-inappbrowser
我基本上:
cordova plugin add cordova-plugin-inappbrowserInAppBrowser我尝试使用插件删除并重新安装无济于事。
关于什么是错误的任何想法?
Usage of ionic-native plugins must wait on the device being "ready"
For Ionic2 with Angular this can be achieved by importing Platform (with every thing else) to whichever component/service you plan on using the ionic-native plugin from.
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { InAppBrowser } from 'ionic-native';
import { Platform } from 'ionic-angular';
Run Code Online (Sandbox Code Playgroud)
and then waiting on the platform being ready:
@Injectable()
export class Service() {
constructor(public platform: Platform) {
this.init()
}
init() {
this.platform.ready().then(() => {
let browser = new InAppBrowser('https://ionic.io', '_system');
browser.on("loadstop").subscribe(()=> console.log("loadstop"));
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5613 次 |
| 最近记录: |