当我尝试使用angular2-google-maps模块的组件时,它给了我这个错误:
无法解析[object Object](?)的所有参数。 ;区域:角;任务:Promise.then;
我看不出这是哪个对象以及错误发生的原因。这也只发生在我使用webpack生成app.bundle时。
我尝试加载的组件是:
import { Component, OnInit} from '@angular/core';
import {userInfo} from '../data/userInfo';
import { Http, Response } from '@angular/http';
import {Router} from '@angular/router';
import {ANGULAR2_GOOGLE_MAPS_DIRECTIVES, ANGULAR2_GOOGLE_MAPS_PROVIDERS} from 'angular2-google-maps/core';
import {ProjectNameComponent} from '../project-name-component/projectName.component';
import {LocationService} from './location.service';
@Component({
selector: 'location',
templateUrl: 'app/location-component/location.component.html',
styleUrls: ['app/location-component/location.component.css', 'app/app.css'],
directives: [ANGULAR2_GOOGLE_MAPS_DIRECTIVES, ProjectNameComponent],
providers: [ANGULAR2_GOOGLE_MAPS_PROVIDERS],
inputs: ['locationShow'],
})
我的systemjs.config.js文件是:
var map = {
'app': 'app', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
'angular2-datatable': 'node_modules/angular2-datatable',
'angular2-google-maps': 'node_modules/angular2-google-maps',
'lodash': 'node_modules/lodash/lodash.js',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'angular2-google-maps': { main: 'core.js', defaultExtension: 'js' },
'angular2-datatable': { defaultExtension: 'js' },
};
我的main.ts文件如下所示:
import 'core-js';
import 'reflect-metadata';
import 'zone.js/dist/zone';
import {enableProdMode} from '@angular/core';
enableProdMode();
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import {APP_ROUTER_PROVIDERS} from './app.router';
import { Http, HTTP_PROVIDERS, Response} from '@angular/http';
bootstrap(AppComponent, [APP_ROUTER_PROVIDERS, HTTP_PROVIDERS]).catch(err => console.error(err));
答案 0 :(得分:0)
显然,Angular 2无法识别依赖性。 ANGULAR2_GOOGLE_MAPS_PROVIDERS
和ANGULAR2_GOOGLE_MAPS_DIRECTIVES
未正确引用。
我用于Angular 2的Google地图版本已经过时了。我会推荐任何想要在他的Angular网站上实施Google地图的人,转到version 0.12.0并且它不应该有任何引用问题。