【发布时间】:2017-02-19 23:52:39
【问题描述】:
我是 Ionic 2 和周围一切的新手。我正在尝试设置我的第一个移动应用程序:触摸一个按钮,我将打开本机导航(例如 Google Maps for Android)。我已经安装了launchnavigator 插件:
ionic plugin add uk.co.workingedge.phonegap.plugin.launchnavigator
在 cremony.ts 页面内:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { LaunchNavigator, LaunchNavigatorOptions } from 'ionic-native';
@Component({
selector: 'page-ceremony',
templateUrl: 'ceremony.html'
})
export class Ceremony {
constructor(public navCtrl: NavController) {
}
navigate() {
let options: LaunchNavigatorOptions = {
start: ""
};
LaunchNavigator.navigate("London, UK", options)
.then(
success => alert('Launched navigator'),
error => alert('Error launching navigator: ' + error)
);
}
}
创建一个 npm run build 并使用 ionic upload 将其上传到 IonicView。
我已经按照this link 中的建议做了所有事情,但运气不同。
但是当我在 Ionic View 中单击按钮(一个简单的 <button ion-button (click)="navigate()">Navigate</button> 在仪式.html 中)时,会出现错误提示:Error launghing navigator: plugin_not_installed。
我检查了项目,plugins 目录包含uk.co.workingedge.phonegap.plugin.launchnavigatorlooks 目录。所以我查看package.json 和config.xml 并在cordovaPlugins 中添加了值uk.co.workingedge.phonegap.plugin.launchnavigator
并在 widget 根中标记 <plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" spec="~3.2.1" />。 npm run build, ionic upload 但没有任何改变。
我的错误在哪里?
【问题讨论】:
-
尝试在
this.platform.ready().then(()=>{})内拨打电话 -
它看起来像 Javascript,而我的代码库在 Typescript 中。有办法把它翻译成 TS 吗?
-
typescript 是 javascript 的超集..
-
另外,它可以与模拟器一起使用吗?
-
我知道,但我想要一个连贯的代码库...从未尝试过使用模拟器。