简体   繁体   English

无法在Angular 2中解析MapsPage :(?,NavController,LaunchNavigator,...)的所有参数

[英]Can't resolve all parameters for MapsPage:(?,NavController,LaunchNavigator,…) in Angular 2

so I am using Angular2 with Ionic2 for my mobile application. 所以我在我的移动应用程序中使用Angular2和Ionic2。 My application was compiling and running perfectly until I added a new module to the application to have navigation in google maps. 我的应用程序正在编译并运行完美,直到我向应用程序添加了一个新模块才能在谷歌地图中导航。 I am using phonegap-launch-navigator to do so. 我正在使用phonegap-launch-navigator这样做。 The class where I am importing the modules is my Maps class and the structure of the class looks like this; 我导入模块的类是我的Maps类,类的结构如下所示;

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());
  }

and my package.json looks like this 我的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"
}

After importing these two modules and putting them in the constructor, I am not able to even start my application and it gives a runtime error saying "Can't resolve all parameters for MapsPage(?,NavController,LaunchNavigator,Platform,NavController,NavParams,NgZone). I think the problem is with LaunchNavigatorOptions because when i comment that one specifically out, the application is able to run again without any problems. Is there anything that I can do to make it work? Any help is appreciated. Thanks! 导入这两个模块并将它们放入构造函数后,我甚至无法启动我的应用程序,它会发出运行时错误,说“无法解析MapsPage的所有参数(?,NavController,LaunchNavigator,Platform,NavController,NavParams, NgZone)。我认为问题在于LaunchNavigatorOptions,因为当我特意评论那个时,应用程序能够再次运行而没有任何问题。我能做些什么来使它工作吗?任何帮助都表示赞赏。谢谢!

Looks like you are using ionic-native v2.2.11 . 看起来你正在使用ionic-native v2.2.11

In this version the plugins are global and static and are not supposed to be injected in the constructor. 在这个版本中,插件是全局的和静态的,不应该在构造函数中注入。 Just remove 只需删除

public LaunchNavigatorOptions: LaunchNavigatorOptions

and

private LaunchNavigator:LaunchNavigator,

from your constructor. 来自你的构造函数。

check the docs for upgrading to ionic-native 3.x 检查文档以升级到ionic-native 3.x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM