Skip to content

Commit 111c1cb

Browse files
committed
Removing the use of ModuleWithProviders
1 parent 84c4189 commit 111c1cb

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ If you wish to optimize loading `plotly.js` in a different way, please check bot
173173

174174
### Plotly Via CDN Module
175175

176-
If you want to load `plotly.js` [from a CDN](https://github.com/plotly/plotly.js#use-the-plotlyjs-cdn-hosted-by-fastly), use the `PlotlyViaCDNModule` and call `forRoot` method with the version you want to use:
176+
If you want to load `plotly.js` [from a CDN](https://github.com/plotly/plotly.js#use-the-plotlyjs-cdn-hosted-by-fastly), use the `PlotlyViaCDNModule` and set on the `PlotlyViaCDNModule.plotlyVersion` property the plotly.js's version you want to use:
177177

178178
```typescript
179179
import { NgModule } from '@angular/core';

src/app/plotly-via-cdn/plotly-via-cdn.module.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModule, ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { PlotComponent } from '../shared/plot/plot.component';
@@ -51,18 +51,8 @@ export class PlotlyViaCDNModule {
5151
fn();
5252
}
5353

54-
static forRoot(config: Partial<{version: string}>): ModuleWithProviders<PlotlyViaCDNModule> {
55-
if (config.version === undefined) {
56-
console.warn(`It's strongly recommended that you set a plotly version when using via CDN.`);
57-
config.version = 'latest';
58-
}
59-
60-
PlotlyViaCDNModule.setPlotlyVersion(config.version);
61-
PlotlyViaCDNModule.loadViaCDN();
62-
63-
return {
64-
ngModule: PlotlyViaCDNModule,
65-
providers: [PlotlyService]
66-
};
54+
static forRoot(config: Partial<{version: string}>): never {
55+
const url = "https://github.com/plotly/angular-plotly.js#customizing-the-plotlyjs-bundle";
56+
throw new Error(`[PlotlyViaCDNModule] forRoot method is deprecated. Please see: ${url}`);
6757
}
6858
}

src/app/plotly-via-window/plotly-via-window.module.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModule, ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { PlotComponent } from '../shared/plot/plot.component';
@@ -22,10 +22,8 @@ export class PlotlyViaWindowModule {
2222
PlotlyService.setPlotly(plotly);
2323
}
2424

25-
static forRoot(): ModuleWithProviders {
26-
return {
27-
ngModule: PlotlyViaWindowModule,
28-
providers: [PlotlyService]
29-
};
25+
static forRoot(): never {
26+
const url = "https://github.com/plotly/angular-plotly.js#plotly-via-window-module";
27+
throw new Error(`[PlotlyViaWindowModule] forRoot method is deprecated. Please see: ${url}`);
3028
}
3129
}

0 commit comments

Comments
 (0)