Browse Source

feat(theme-shared): create append-content.token

pull/3475/head
mehmet-erim 7 years ago
parent
commit
310a561661
  1. 12
      npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts
  2. 15
      npm/ng-packs/packages/theme-shared/src/lib/tokens/append-content.token.ts

12
npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts

@ -1,4 +1,4 @@
import { CoreModule, LazyLoadService } from '@abp/ng.core';
import { CoreModule, noop, LazyLoadService } from '@abp/ng.core';
import { DatePipe } from '@angular/common';
import { APP_INITIALIZER, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { NgbDateParserFormatter, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
@ -25,7 +25,13 @@ import { chartJsLoaded$ } from './utils/widget-utils';
import { PaginationComponent } from './components/pagination/pagination.component';
import { LoadingComponent } from './components/loading/loading.component';
import { LoadingDirective } from './directives/loading.directive';
import { THEME_SHARED_APPEND_CONTENT } from './tokens/append-content.token';
/**
*
* @deprecated To be deleted in v2.6
*
*/
export function appendScript(injector: Injector) {
const fn = () => {
import('chart.js').then(() => chartJsLoaded$.next(true));
@ -87,8 +93,8 @@ export class ThemeSharedModule {
{
provide: APP_INITIALIZER,
multi: true,
deps: [Injector],
useFactory: appendScript,
deps: [THEME_SHARED_APPEND_CONTENT],
useFactory: noop,
},
{ provide: HTTP_ERROR_CONFIG, useValue: options.httpErrorConfig },
{

15
npm/ng-packs/packages/theme-shared/src/lib/tokens/append-content.token.ts

@ -0,0 +1,15 @@
import { CONTENT_STRATEGY, DOMInsertionService } from '@abp/ng.core';
import { inject, InjectionToken } from '@angular/core';
import styles from '../constants/styles';
import { chartJsLoaded$ } from '../utils/widget-utils';
export const THEME_SHARED_APPEND_CONTENT = new InjectionToken<void>('THEME_SHARED_APPEND_CONTENT', {
providedIn: 'root',
factory: () => {
const domInsertion: DOMInsertionService = inject(DOMInsertionService);
domInsertion.insertElement(CONTENT_STRATEGY.AppendStyleToHead(styles));
import('chart.js').then(() => chartJsLoaded$.next(true));
},
});
Loading…
Cancel
Save