Skip to content

Commit

Permalink
feat(*): support @NgModule
Browse files Browse the repository at this point in the history
This adds a new NgModule to the project. The Module name for the
core package is `AgmCoreModule`. This feature is experimental.

Example:

```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from
'@angular/platform-browser-dynamic';
import { MyMapsProjectAppComponent } from './app/';

import {AgmCoreModule} from 'angular2-google-maps/core';

@NgModule({
	  imports: [BrowserModule, AgmCoreModule.forRoot()],
		declarations: [MyMapsProjectAppComponent],
	  bootstrap: [MyMapsProjectAppComponent]
})
export class AppModule {
}

platformBrowserDynamic().bootstrapModule(AppModule);
```

Closes #560
Closes #571
  • Loading branch information
sebholstein committed Aug 15, 2016
1 parent b8f4680 commit 1d0cd9c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
Expand Down Expand Up @@ -76,10 +74,8 @@
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
Expand Down
1 change: 1 addition & 0 deletions src/core/directives-const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {SebmGoogleMapMarker} from './directives/google-map-marker';
import {SebmGoogleMapPolyline} from './directives/google-map-polyline';
import {SebmGoogleMapPolylinePoint} from './directives/google-map-polyline-point';

/** @deprecated */
export const GOOGLE_MAPS_DIRECTIVES: any[] = [
SebmGoogleMap, SebmGoogleMapMarker, SebmGoogleMapInfoWindow, SebmGoogleMapCircle,
SebmGoogleMapPolyline, SebmGoogleMapPolylinePoint
Expand Down
21 changes: 19 additions & 2 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {provide} from '@angular/core';
import {ModuleWithProviders, NgModule, provide} from '@angular/core';

import {GOOGLE_MAPS_DIRECTIVES} from './directives-const';
import {LazyMapsAPILoader} from './services/maps-api-loader/lazy-maps-api-loader';
import {MapsAPILoader} from './services/maps-api-loader/maps-api-loader';

import {BROWSER_GLOBALS_PROVIDERS} from './utils/browser-globals';

// main modules
Expand All @@ -13,7 +13,24 @@ export * from './map-types';
// Google Maps types
export {LatLngBounds, LatLng, LatLngLiteral, MapTypeStyle} from './services/google-maps-types';

/** @deprecated */
export const GOOGLE_MAPS_PROVIDERS: any[] = [
BROWSER_GLOBALS_PROVIDERS,
provide(MapsAPILoader, {useClass: LazyMapsAPILoader}),
];

/**
* The angular2-google-maps core module. Contains all Directives/Services/Pipes
* of the core module. Please use `AgmCoreModule.forRoot()` in your app module.
*
* @experimental
*/
@NgModule({declarations: GOOGLE_MAPS_DIRECTIVES, exports: GOOGLE_MAPS_DIRECTIVES})
export class AgmCoreModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: AgmCoreModule,
providers: GOOGLE_MAPS_PROVIDERS,
};
}
}

0 comments on commit 1d0cd9c

Please sign in to comment.