我有一個Ionic v2應用程序。angular2-google-maps導致ctorParameters.map錯誤
我一直在努力實現angular2-google-maps的年齡,但不斷收到錯誤:
TypeError: ctorParameters.map is not a function
我packages.json
(依賴):
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/compiler-cli": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/platform-server": "2.3.1",
"@ionic/storage": "1.1.6",
"angular2-google-maps": "^0.17.0",
"angularfire2": "^2.0.0-beta.6",
"firebase": "^3.6.4",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.3",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.7.4"
},
尋找here和問題相似,我更新我所有的軟件包(我認爲是)正確的版本(即從rc3到rc4的ionic-angular
),從我所能看到的情況來看,這個錯誤通常是由於錯誤包版本的匹配。
我遵循this教程,但他談到與離子集成不同的問題,並沒有解決我自己的問題。
我app.module.ts
遵循相同tutorial:
import { AgmCoreModule } from "angular2-google-maps/core";
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
// AgmCoreModule.forRoot({
// apiKey: "AIzaSyDUdGaRHXhN5oy5zpETRll8KsHnvx19_9Y"
// }),
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)
],
由於這些代碼是,它會工作。但是,如果我取消註釋AgmCoreModule.forRoot()
即我收到錯誤時。
我找不到任何人在任何地方複製或有相同的錯誤。
另外,開始一個空白的離子v2項目具有相同的依賴關係,並啓用AgmCoreModule.forRoot()
作品,這使我相信它可能是我的項目。但是,所有的配置完全相同,我不知道其他什麼會導致此錯誤。
答:
錯誤是angular2-google-maps
版本。我使用的是0.17.0
,而0.16.0
是Ionic v2應用程序所必需的。下面的答案描述了降級角度版本可能會有幫助,但我不認爲這是必要的。在任何情況下,這是我的package.json
一套新的依賴關係:
"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/storage": "1.1.7",
"angular2-google-maps": "0.16.0",
"angularfire2": "^2.0.0-beta.6",
"firebase": "^3.6.4",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.11",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
}
將'angular2-google-maps'版本降級到'0.16.0'已成功!非常感謝你 – wmash
很高興它解決了:) –