我想谷歌地图功能添加到我的应用程序页面中的一个,我下面这个教程:http://www.joshmorony.com/creating-an-advanced-google-maps-component-in-ionic-2/如何将连接服务提供程序添加到我的应用程序?
在阶段1,我需要更新我的app.module.ts包括在该ConnectivityService
提供者列表。
该页面提供了一个例子,但在我的应用程序已经有两家供应商,导致我有另外之前下列app.module.ts:
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { Page1 } from '../pages/page1/page1';
import { Page2 } from '../pages/page2/page2';
import { MapPage } from '../pages/map/map';
@NgModule({
declarations: [
MyApp,
Page1,
Page2,
MapPage
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Page1,
Page2,
MapPage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
然后,以适应我的教程“VE之初
import { ConnectivityService } from '../providers/connectivity-service';
添加和更改我的供应商:
提供商:[{提供:的ErrorHandler,useClass:IonicErrorHandler,ConnectivityService} ]
,但我得到一个错误:
Argument of type '{ declarations: (typeof Page1 | typeof Page2 | typeof MyApp)[]; imports: ModuleWithProviders[]; b...' is not assignable to parameter of type 'NgModule'. Types of property 'providers' are incompatible. Type '{ provide: typeof ErrorHandler; useClass: typeof IonicErrorHandler; ConnectivityService: typeof C...' is not assignable to type 'Provider[]'. Type '{ provide: typeof ErrorHandler; useClass: typeof IonicErrorHandler; ConnectivityService: typeof C...' is not assignable to type 'Provider'. Object literal may only specify known properties, and 'ConnectivityService' does not exist in type 'Provider'.
的我有同样的错误,如果我更改为:
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler, connectivityService:ConnectivityService}]
什么是我做的正确方法?
谢谢!