因此我將Angular2與Ionic2一起用於我的移動應用程序。我的應用程序正在編譯和運行完美,直到我添加一個新的模塊到應用程序的導航谷歌地圖。我正在使用phonegap-launch-navigator來做到這一點。我導入模塊的類是我的Maps類,而類的結構如下所示;無法解析Angular 2中的MapsPage :(?,NavController,LaunchNavigator,.......)的所有參數
import { LaunchNavigator, LaunchNavigatorOptions} from 'ionic-native';
import { Component, NgZone } from "@angular/core";
import { NavController, Platform, NavParams } from 'ionic-angular';
import {GoogleMap, GoogleMapsEvent, GoogleMapsLatLng, GoogleMapsMarkerOptions, CameraPosition } from 'ionic-native';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Geolocation } from 'ionic-native';
import { Injectable,forwardRef,Inject } from "@angular/core";
@Component({
selector: 'maps-page',
templateUrl: 'maps.html',
})
export class MapsPage {
private map: GoogleMap;
destination:string;
start:string;
constructor(public LaunchNavigatorOptions: LaunchNavigatorOptions,
private _navController: NavController,
private LaunchNavigator:LaunchNavigator,
private platform: Platform,
public navCtrl: NavController,
public navParams: NavParams,
private _zone: NgZone) {
this.start = "";
this.destination = "Westminster, London, UK";
this.platform.ready().then(() => this.onPlatformReady());
}
和我的package.json看起來像這樣
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"test": "mocha"
},
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/cloud-angular": "^0.11.0",
"@ionic/storage": "1.1.7",
"angular2-jwt": "^0.1.28",
"bootstrap": "^3.3.7",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.11",
"ionicons": "3.0.0",
"jquery": "^3.1.1",
"moment": "^2.17.1",
"ng2-translate": "^5.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
},
"devDependencies": {
"@ionic/app-scripts": "^1.0.0",
"typescript": "2.0.9"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios",
{
"platform": "ios",
"version": "",
"locator": "ios"
}
],
"description": "myApp: An Ionic project"
}
導入這兩個模塊並把它們在構造後,我無法甚至開始我的應用程序,它提供了一個運行時錯誤說法「無法解析MapsPage(?,NavController,LaunchNavigator,Platform,NavController,NavParams,NgZone)的所有參數。我認爲問題出在LaunchNavigatorOptions上,因爲當我特意發表一個意見時,應用程序可以在沒有任何問題有什麼,我可以做,使其工作?任何幫助表示讚賞。謝謝!
你能告訴你'package.json'文件? – Sampath
@Sampath,我編輯了我的帖子。你現在可以看到它。謝謝! – BleachedAxe