plotly / plotly/angular-plotly.js

TypeError: PlotlyService.plotly.purge is not a function

未關閉
#180 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
TypeScript
星號
242
分支
81
平均合併
8 小時 48 分鐘
30 天內合併 PR
18

描述

Getting this error when switching active submodules

core.js:6486 ERROR Error: Uncaught (in promise): TypeError: PlotlyService.plotly.purge is not a function
TypeError: PlotlyService.plotly.purge is not a function
    at Function.remove (:4200/default-src_app_service_comp-reg_service_ts.js:25186)
    at PlotlyComponent.ngOnDestroy (:4200/default-src_app_service_comp-reg_service_ts.js:25348)
    at executeOnDestroys (:4200/vendor.js:32351)
    at cleanUpView (:4200/vendor.js:32254)
    at destroyViewTree (:4200/vendor.js:32080)
    at destroyLView (:4200/vendor.js:32232)
    at RootViewRef.destroy (:4200/vendor.js:47596)
    at ComponentRef$1.destroy (:4200/vendor.js:50130)
    at RouterOutlet.deactivate (:4200/vendor.js:93334)
    at ActivateRoutes.deactivateRouteAndOutlet (:4200/vendor.js:89858)
    at resolvePromise (:4200/polyfills.js:1222)
    at resolvePromise (:4200/polyfills.js:1176)
    at :4200/polyfills.js:1288
    at ZoneDelegate.invokeTask (:4200/polyfills.js:415)
    at Object.onInvokeTask (:4200/vendor.js:53612)
    at ZoneDelegate.invokeTask (:4200/polyfills.js:414)
    at Zone.runTask (:4200/polyfills.js:187)
    at drainMicroTaskQueue (:4200/polyfills.js:591)
defaultErrorLogger @ core.js:6486

Submodule config:

...
import { PlotlyViaCDNModule } from 'angular-plotly.js';

PlotlyViaCDNModule.setPlotlyVersion('latest');
PlotlyViaCDNModule.setPlotlyBundle('finance');

@NgModule({
  declarations: [
    DcComponent,
    DcChartComponent,
    ...
  ],
  imports: [
    CommonModule,
    DcRoutingModule,
    ...
    PlotlyViaCDNModule,
    ...
  ]
  ...
}
export class DcModule { }

Note that the scenario is that the Plotly Data Card is configured and saved in one module, then dynamically loaded and displayed in another module. The error occurs sometimes when switching contexts (modules). I guess when the second by loading order is first loaded.

Env:

$ npm list angular-plotly.js
...
└── angular-plotly.js@4.0.4 
$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.2.12
Node: 14.17.0
Package Manager: npm 7.20.5
OS: linux x64

Angular: 12.2.12
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.12
@angular-devkit/build-angular   12.2.12
@angular-devkit/core            12.2.12
@angular-devkit/schematics      12.2.12
@angular/flex-layout            12.0.0-beta.35
@schematics/angular             12.2.12
rxjs                            6.6.7
typescript                      4.3.5
    

Thanks.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先重現動態模組切換的情境,然後在 angular-plotly.js 中追蹤 PlotlyComponent.ngOnDestroy 和 PlotlyService.plotly.purge。比較 PlotlyViaCDNModule 在兩個模組中的設定與載入方式;當切換內容不再引發 purge TypeError 時即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
frontend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。