Commit b71e0e3c810ef62dd6a9b90e9c2dbf563a8875c6

Authored by Igor Kulikov
Committed by GitHub
2 parents 095dbc63 64d4d901

Merge pull request #4043 from ChantsovaEkaterina/improvement/replace-deprecated-portal-injector

Refactoring: replace deprecated PortalInjector
... ... @@ -14,14 +14,23 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { Component, Input, OnDestroy, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
  17 +import {
  18 + Component,
  19 + Injector,
  20 + Input,
  21 + OnDestroy,
  22 + OnInit,
  23 + StaticProvider,
  24 + ViewChild,
  25 + ViewContainerRef
  26 +} from '@angular/core';
18 27 import { TooltipPosition } from '@angular/material/tooltip';
19 28 import { AliasInfo, IAliasController } from '@core/api/widget-api.models';
20 29 import { CdkOverlayOrigin, ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
21 30 import { TranslateService } from '@ngx-translate/core';
22 31 import { Subscription } from 'rxjs';
23 32 import { BreakpointObserver } from '@angular/cdk/layout';
24   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  33 +import { ComponentPortal } from '@angular/cdk/portal';
25 34 import {
26 35 ALIASES_ENTITY_SELECT_PANEL_DATA,
27 36 AliasesEntitySelectPanelComponent,
... ... @@ -136,12 +145,12 @@ export class AliasesEntitySelectComponent implements OnInit, OnDestroy {
136 145 overlayRef.attach(new ComponentPortal(AliasesEntitySelectPanelComponent, this.viewContainerRef, injector));
137 146 }
138 147
139   - private _createAliasesEntitySelectPanelInjector(overlayRef: OverlayRef, data: AliasesEntitySelectPanelData): PortalInjector {
140   - const injectionTokens = new WeakMap<any, any>([
141   - [ALIASES_ENTITY_SELECT_PANEL_DATA, data],
142   - [OverlayRef, overlayRef]
143   - ]);
144   - return new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  148 + private _createAliasesEntitySelectPanelInjector(overlayRef: OverlayRef, data: AliasesEntitySelectPanelData): Injector {
  149 + const providers: StaticProvider[] = [
  150 + {provide: ALIASES_ENTITY_SELECT_PANEL_DATA, useValue: data},
  151 + {provide: OverlayRef, useValue: overlayRef}
  152 + ];
  153 + return Injector.create({parent: this.viewContainerRef.injector, providers});
145 154 }
146 155
147 156 private updateDisplayValue() {
... ...
... ... @@ -19,9 +19,11 @@ import {
19 19 ChangeDetectionStrategy,
20 20 Component,
21 21 ElementRef,
  22 + Injector,
22 23 Input,
23 24 NgZone,
24 25 OnInit,
  26 + StaticProvider,
25 27 ViewChild,
26 28 ViewContainerRef
27 29 } from '@angular/core';
... ... @@ -62,7 +64,7 @@ import {
62 64 EditAttributeValuePanelComponent,
63 65 EditAttributeValuePanelData
64 66 } from './edit-attribute-value-panel.component';
65   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  67 +import { ComponentPortal } from '@angular/cdk/portal';
66 68 import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service';
67 69 import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
68 70 import { DataKey, Datasource, DatasourceType, Widget, widgetType } from '@shared/models/widget.models';
... ... @@ -319,13 +321,19 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
319 321 overlayRef.backdropClick().subscribe(() => {
320 322 overlayRef.dispose();
321 323 });
322   - const injectionTokens = new WeakMap<any, any>([
323   - [EDIT_ATTRIBUTE_VALUE_PANEL_DATA, {
324   - attributeValue: attribute.value
325   - } as EditAttributeValuePanelData],
326   - [OverlayRef, overlayRef]
327   - ]);
328   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  324 + const providers: StaticProvider[] = [
  325 + {
  326 + provide: EDIT_ATTRIBUTE_VALUE_PANEL_DATA,
  327 + useValue: {
  328 + attributeValue: attribute.value
  329 + } as EditAttributeValuePanelData
  330 + },
  331 + {
  332 + provide: OverlayRef,
  333 + useValue: overlayRef
  334 + }
  335 + ];
  336 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
329 337 const componentRef = overlayRef.attach(new ComponentPortal(EditAttributeValuePanelComponent,
330 338 this.viewContainerRef, injector));
331 339 componentRef.onDestroy(() => {
... ...
... ... @@ -14,7 +14,16 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { Component, Input, OnDestroy, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
  17 +import {
  18 + Component,
  19 + Injector,
  20 + Input,
  21 + OnDestroy,
  22 + OnInit,
  23 + StaticProvider,
  24 + ViewChild,
  25 + ViewContainerRef
  26 +} from '@angular/core';
18 27 import { TooltipPosition } from '@angular/material/tooltip';
19 28 import { IAliasController } from '@core/api/widget-api.models';
20 29 import { CdkOverlayOrigin, ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
... ... @@ -28,7 +37,7 @@ import {
28 37 FiltersEditPanelComponent,
29 38 FiltersEditPanelData
30 39 } from '@home/components/filter/filters-edit-panel.component';
31   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  40 +import { ComponentPortal } from '@angular/cdk/portal';
32 41 import { UserFilterDialogComponent, UserFilterDialogData } from '@home/components/filter/user-filter-dialog.component';
33 42 import { MatDialog } from '@angular/material/dialog';
34 43
... ... @@ -153,12 +162,12 @@ export class FiltersEditComponent implements OnInit, OnDestroy {
153 162 }
154 163 }
155 164
156   - private _createFiltersEditPanelInjector(overlayRef: OverlayRef, data: FiltersEditPanelData): PortalInjector {
157   - const injectionTokens = new WeakMap<any, any>([
158   - [FILTER_EDIT_PANEL_DATA, data],
159   - [OverlayRef, overlayRef]
160   - ]);
161   - return new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  165 + private _createFiltersEditPanelInjector(overlayRef: OverlayRef, data: FiltersEditPanelData): Injector {
  166 + const providers: StaticProvider[] = [
  167 + {provide: FILTER_EDIT_PANEL_DATA, useValue: data},
  168 + {provide: OverlayRef, useValue: overlayRef}
  169 + ];
  170 + return Injector.create({parent: this.viewContainerRef.injector, providers});
162 171 }
163 172
164 173 private updateFiltersInfo() {
... ...
... ... @@ -14,11 +14,22 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { Component, forwardRef, Inject, Input, OnDestroy, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
  17 +import {
  18 + Component,
  19 + forwardRef,
  20 + Inject,
  21 + Injector,
  22 + Input,
  23 + OnDestroy,
  24 + OnInit,
  25 + StaticProvider,
  26 + ViewChild,
  27 + ViewContainerRef
  28 +} from '@angular/core';
18 29 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
19 30 import { DOCUMENT } from '@angular/common';
20 31 import { CdkOverlayOrigin, ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
21   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  32 +import { ComponentPortal } from '@angular/cdk/portal';
22 33 import { MediaBreakpoints } from '@shared/models/constants';
23 34 import { BreakpointObserver } from '@angular/cdk/layout';
24 35 import { WINDOW } from '@core/services/window.service';
... ... @@ -140,12 +151,12 @@ export class LegendConfigComponent implements OnInit, OnDestroy, ControlValueAcc
140 151 overlayRef.attach(new ComponentPortal(LegendConfigPanelComponent, this.viewContainerRef, injector));
141 152 }
142 153
143   - private _createLegendConfigPanelInjector(overlayRef: OverlayRef, data: LegendConfigPanelData): PortalInjector {
144   - const injectionTokens = new WeakMap<any, any>([
145   - [LEGEND_CONFIG_PANEL_DATA, data],
146   - [OverlayRef, overlayRef]
147   - ]);
148   - return new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  154 + private _createLegendConfigPanelInjector(overlayRef: OverlayRef, data: LegendConfigPanelData): Injector {
  155 + const providers: StaticProvider[] = [
  156 + {provide: LEGEND_CONFIG_PANEL_DATA, useValue: data},
  157 + {provide: OverlayRef, useValue: overlayRef}
  158 + ];
  159 + return Injector.create({parent: this.viewContainerRef.injector, providers});
149 160 }
150 161
151 162 registerOnChange(fn: any): void {
... ...
... ... @@ -19,9 +19,11 @@ import {
19 19 Component,
20 20 ElementRef,
21 21 EventEmitter,
  22 + Injector,
22 23 Input,
23 24 NgZone,
24 25 OnInit,
  26 + StaticProvider,
25 27 ViewChild,
26 28 ViewContainerRef
27 29 } from '@angular/core';
... ... @@ -64,7 +66,7 @@ import {
64 66 widthStyle
65 67 } from '@home/components/widget/lib/table-widget.models';
66 68 import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
67   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  69 +import { ComponentPortal } from '@angular/cdk/portal';
68 70 import {
69 71 DISPLAY_COLUMNS_PANEL_DATA,
70 72 DisplayColumnsPanelComponent,
... ... @@ -452,20 +454,26 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
452 454 };
453 455 });
454 456
455   - const injectionTokens = new WeakMap<any, any>([
456   - [DISPLAY_COLUMNS_PANEL_DATA, {
457   - columns,
458   - columnsUpdated: (newColumns) => {
459   - this.displayedColumns = newColumns.filter(column => column.display).map(column => column.def);
460   - if (this.enableSelection) {
461   - this.displayedColumns.unshift('select');
  457 + const providers: StaticProvider[] = [
  458 + {
  459 + provide: DISPLAY_COLUMNS_PANEL_DATA,
  460 + useValue: {
  461 + columns,
  462 + columnsUpdated: (newColumns) => {
  463 + this.displayedColumns = newColumns.filter(column => column.display).map(column => column.def);
  464 + if (this.enableSelection) {
  465 + this.displayedColumns.unshift('select');
  466 + }
  467 + this.displayedColumns.push('actions');
462 468 }
463   - this.displayedColumns.push('actions');
464   - }
465   - } as DisplayColumnsPanelData],
466   - [OverlayRef, overlayRef]
467   - ]);
468   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  469 + } as DisplayColumnsPanelData
  470 + },
  471 + {
  472 + provide: OverlayRef,
  473 + useValue: overlayRef
  474 + }
  475 + ];
  476 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
469 477 overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
470 478 this.viewContainerRef, injector));
471 479 this.ctx.detectChanges();
... ... @@ -492,15 +500,21 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
492 500 overlayRef.backdropClick().subscribe(() => {
493 501 overlayRef.dispose();
494 502 });
495   - const injectionTokens = new WeakMap<any, any>([
496   - [ALARM_FILTER_PANEL_DATA, {
497   - statusList: this.pageLink.statusList,
498   - severityList: this.pageLink.severityList,
499   - typeList: this.pageLink.typeList
500   - } as AlarmFilterPanelData],
501   - [OverlayRef, overlayRef]
502   - ]);
503   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  503 + const providers: StaticProvider[] = [
  504 + {
  505 + provide: ALARM_FILTER_PANEL_DATA,
  506 + useValue: {
  507 + statusList: this.pageLink.statusList,
  508 + severityList: this.pageLink.severityList,
  509 + typeList: this.pageLink.typeList
  510 + } as AlarmFilterPanelData
  511 + },
  512 + {
  513 + provide: OverlayRef,
  514 + useValue: overlayRef
  515 + }
  516 + ];
  517 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
504 518 const componentRef = overlayRef.attach(new ComponentPortal(AlarmFilterPanelComponent,
505 519 this.viewContainerRef, injector));
506 520 componentRef.onDestroy(() => {
... ...
... ... @@ -18,9 +18,11 @@ import {
18 18 Component,
19 19 Inject,
20 20 InjectionToken,
  21 + Injector,
21 22 Input,
22 23 OnDestroy,
23 24 OnInit,
  25 + StaticProvider,
24 26 ViewChild,
25 27 ViewContainerRef,
26 28 ViewEncapsulation
... ... @@ -41,7 +43,7 @@ import {
41 43 import { KeyValue } from '@angular/common';
42 44 import * as _moment from 'moment';
43 45 import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
44   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  46 +import { ComponentPortal } from '@angular/cdk/portal';
45 47 import { MatSelect } from '@angular/material/select';
46 48 import { Subscription } from 'rxjs';
47 49 import { HistoryWindowType, TimewindowType } from '@shared/models/time/time.models';
... ... @@ -142,18 +144,24 @@ export class DateRangeNavigatorWidgetComponent extends PageComponent implements
142 144 overlayRef.backdropClick().subscribe(() => {
143 145 overlayRef.dispose();
144 146 });
145   - const injectionTokens = new WeakMap<any, any>([
146   - [DATE_RANGE_NAVIGATOR_PANEL_DATA, {
147   - model: cloneDateRangeNavigatorModel(this.advancedModel),
148   - settings: this.settings,
149   - onChange: model => {
150   - this.advancedModel = model;
151   - this.triggerChange();
152   - }
153   - } as DateRangeNavigatorPanelData],
154   - [OverlayRef, overlayRef]
155   - ]);
156   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  147 + const providers: StaticProvider[] = [
  148 + {
  149 + provide: DATE_RANGE_NAVIGATOR_PANEL_DATA,
  150 + useValue: {
  151 + model: cloneDateRangeNavigatorModel(this.advancedModel),
  152 + settings: this.settings,
  153 + onChange: model => {
  154 + this.advancedModel = model;
  155 + this.triggerChange();
  156 + }
  157 + } as DateRangeNavigatorPanelData
  158 + },
  159 + {
  160 + provide: OverlayRef,
  161 + useValue: overlayRef
  162 + }
  163 + ];
  164 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
157 165 overlayRef.attach(new ComponentPortal(DateRangeNavigatorPanelComponent,
158 166 this.viewContainerRef, injector));
159 167 this.ctx.detectChanges();
... ...
... ... @@ -18,9 +18,11 @@ import {
18 18 AfterViewInit,
19 19 Component,
20 20 ElementRef,
  21 + Injector,
21 22 Input,
22 23 NgZone,
23 24 OnInit,
  25 + StaticProvider,
24 26 ViewChild,
25 27 ViewContainerRef
26 28 } from '@angular/core';
... ... @@ -70,7 +72,7 @@ import {
70 72 widthStyle
71 73 } from '@home/components/widget/lib/table-widget.models';
72 74 import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
73   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  75 +import { ComponentPortal } from '@angular/cdk/portal';
74 76 import {
75 77 DISPLAY_COLUMNS_PANEL_DATA,
76 78 DisplayColumnsPanelComponent,
... ... @@ -422,17 +424,23 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
422 424 };
423 425 });
424 426
425   - const injectionTokens = new WeakMap<any, any>([
426   - [DISPLAY_COLUMNS_PANEL_DATA, {
427   - columns,
428   - columnsUpdated: (newColumns) => {
429   - this.displayedColumns = newColumns.filter(column => column.display).map(column => column.def);
430   - this.displayedColumns.push('actions');
431   - }
432   - } as DisplayColumnsPanelData],
433   - [OverlayRef, overlayRef]
434   - ]);
435   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  427 + const providers: StaticProvider[] = [
  428 + {
  429 + provide: DISPLAY_COLUMNS_PANEL_DATA,
  430 + useValue: {
  431 + columns,
  432 + columnsUpdated: (newColumns) => {
  433 + this.displayedColumns = newColumns.filter(column => column.display).map(column => column.def);
  434 + this.displayedColumns.push('actions');
  435 + }
  436 + } as DisplayColumnsPanelData
  437 + },
  438 + {
  439 + provide: OverlayRef,
  440 + useValue: overlayRef
  441 + }
  442 + ];
  443 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
436 444 overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
437 445 this.viewContainerRef, injector));
438 446 this.ctx.detectChanges();
... ...
... ... @@ -14,7 +14,17 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { Component, forwardRef, Inject, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
  17 +import {
  18 + Component,
  19 + forwardRef,
  20 + Inject,
  21 + Injector,
  22 + Input,
  23 + OnInit,
  24 + StaticProvider,
  25 + ViewChild,
  26 + ViewContainerRef
  27 +} from '@angular/core';
18 28 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
19 29 import { Observable, of } from 'rxjs';
20 30 import { PageLink } from '@shared/models/page/page-link';
... ... @@ -32,7 +42,7 @@ import { CdkOverlayOrigin, ConnectedPosition, Overlay, OverlayConfig, OverlayRef
32 42 import { BreakpointObserver } from '@angular/cdk/layout';
33 43 import { DOCUMENT } from '@angular/common';
34 44 import { WINDOW } from '@core/services/window.service';
35   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  45 +import { ComponentPortal } from '@angular/cdk/portal';
36 46 import {
37 47 DASHBOARD_SELECT_PANEL_DATA,
38 48 DashboardSelectPanelComponent,
... ... @@ -186,12 +196,12 @@ export class DashboardSelectComponent implements ControlValueAccessor, OnInit {
186 196 overlayRef.attach(new ComponentPortal(DashboardSelectPanelComponent, this.viewContainerRef, injector));
187 197 }
188 198
189   - private _createDashboardSelectPanelInjector(overlayRef: OverlayRef, data: DashboardSelectPanelData): PortalInjector {
190   - const injectionTokens = new WeakMap<any, any>([
191   - [DASHBOARD_SELECT_PANEL_DATA, data],
192   - [OverlayRef, overlayRef]
193   - ]);
194   - return new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  199 + private _createDashboardSelectPanelInjector(overlayRef: OverlayRef, data: DashboardSelectPanelData): Injector {
  200 + const providers: StaticProvider[] = [
  201 + {provide: DASHBOARD_SELECT_PANEL_DATA, useValue: data},
  202 + {provide: OverlayRef, useValue: overlayRef}
  203 + ];
  204 + return Injector.create({parent: this.viewContainerRef.injector, providers});
195 205 }
196 206
197 207 private updateView() {
... ...
... ... @@ -14,7 +14,18 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { Component, forwardRef, Inject, Input, OnDestroy, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
  17 +import {
  18 + Component,
  19 + forwardRef,
  20 + Inject,
  21 + Injector,
  22 + Input,
  23 + OnDestroy,
  24 + OnInit,
  25 + StaticProvider,
  26 + ViewChild,
  27 + ViewContainerRef
  28 +} from '@angular/core';
18 29 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
19 30 import { TranslateService } from '@ngx-translate/core';
20 31 import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-string.pipe';
... ... @@ -32,7 +43,7 @@ import {
32 43 TimewindowPanelComponent,
33 44 TimewindowPanelData
34 45 } from '@shared/components/time/timewindow-panel.component';
35   -import { ComponentPortal, PortalInjector } from '@angular/cdk/portal';
  46 +import { ComponentPortal } from '@angular/cdk/portal';
36 47 import { MediaBreakpoints } from '@shared/models/constants';
37 48 import { BreakpointObserver } from '@angular/cdk/layout';
38 49 import { WINDOW } from '@core/services/window.service';
... ... @@ -229,12 +240,12 @@ export class TimewindowComponent implements OnInit, OnDestroy, ControlValueAcces
229 240 });
230 241 }
231 242
232   - private _createTimewindowPanelInjector(overlayRef: OverlayRef, data: TimewindowPanelData): PortalInjector {
233   - const injectionTokens = new WeakMap<any, any>([
234   - [TIMEWINDOW_PANEL_DATA, data],
235   - [OverlayRef, overlayRef]
236   - ]);
237   - return new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  243 + private _createTimewindowPanelInjector(overlayRef: OverlayRef, data: TimewindowPanelData): Injector {
  244 + const providers: StaticProvider[] = [
  245 + {provide: TIMEWINDOW_PANEL_DATA, useValue: data},
  246 + {provide: OverlayRef, useValue: overlayRef}
  247 + ];
  248 + return Injector.create({parent: this.viewContainerRef.injector, providers});
238 249 }
239 250
240 251 registerOnChange(fn: any): void {
... ...
... ... @@ -20,9 +20,11 @@ import {
20 20 Directive,
21 21 ElementRef, HostBinding,
22 22 Inject,
  23 + Injector,
23 24 Input,
24 25 NgZone,
25 26 OnDestroy, Optional,
  27 + StaticProvider,
26 28 ViewChild,
27 29 ViewContainerRef
28 30 } from '@angular/core';
... ... @@ -34,7 +36,6 @@ import { BreakpointObserver } from '@angular/cdk/layout';
34 36 import { MediaBreakpoints } from '@shared/models/constants';
35 37 import { MatButton } from '@angular/material/button';
36 38 import Timeout = NodeJS.Timeout;
37   -import { PortalInjector } from '@angular/cdk/portal';
38 39
39 40 @Directive({
40 41 selector: '[tb-toast]'
... ... @@ -138,10 +139,10 @@ export class ToastDirective implements AfterViewInit, OnDestroy {
138 139 this.toastComponentRef.destroy();
139 140 }
140 141 };
141   - const injectionTokens = new WeakMap<any, any>([
142   - [MAT_SNACK_BAR_DATA, data]
143   - ]);
144   - const injector = new PortalInjector(this.viewContainerRef.injector, injectionTokens);
  142 + const providers: StaticProvider[] = [
  143 + {provide: MAT_SNACK_BAR_DATA, useValue: data}
  144 + ];
  145 + const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
145 146 this.toastComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
146 147 this.cd.detectChanges();
147 148
... ...