@angular/core#ModuleWithProviders TypeScript Examples

The following examples show how to use @angular/core#ModuleWithProviders. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: test.utils.ts    From WowUp with GNU General Public License v3.0 7 votes vote down vote up
export function createTranslateModule(): ModuleWithProviders<TranslateModule> {
  return TranslateModule.forRoot({
    loader: {
      provide: TranslateLoader,
      useFactory: testHttpLoaderFactory,
      deps: [HttpClient],
    },
    compiler: {
      provide: TranslateCompiler,
      useClass: TranslateMessageFormatCompiler,
    },
  });
}
Example #2
Source File: icon.module.ts    From ng-icons with MIT License 6 votes vote down vote up
/**
   * Define the icons that will be included in the application. This allows unused icons to
   * be tree-shaken away to reduce bundle size
   * @param icons The object containing the required icons
   */
  static withIcons(
    icons: Record<string, string>,
  ): ModuleWithProviders<NgIconsModule> {
    IconService.addIcons(icons);

    return { ngModule: NgIconsModule };
  }
Example #3
Source File: api.module.ts    From mycoradar with MIT License 6 votes vote down vote up
static forRoot(customParams: ApiConfigurationInterface): ModuleWithProviders<ApiModule> {
    return {
      ngModule: ApiModule,
      providers: [
        {
          provide: ApiConfiguration,
          useValue: {rootUrl: customParams.rootUrl}
        }
      ]
    }
  }
Example #4
Source File: console.module.ts    From ngx-ui-tour with MIT License 6 votes vote down vote up
public static forRoot(): ModuleWithProviders<TourConsoleModule> {
    return {
      ngModule: TourConsoleModule,
      providers: [
        TourService,
        TourBackdropService
      ],
    };
  }
Example #5
Source File: mobile.module.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
static forRoot(): ModuleWithProviders<MobileModule> {
    return {
      ngModule: MobileModule,
      providers: [
        QrScannerService,
        QRScanner,
        DeviceAuthService,
        AndroidFingerprintAuth,
        {
          provide: 'TouchID',
          useValue: TouchID,
        },
        {
          provide: 'Keychain',
          useValue: Keychain,
        },
      ],
    };
  }
Example #6
Source File: ngx-bootstrap.module.ts    From ngx-ui-tour with MIT License 6 votes vote down vote up
public static forRoot(): ModuleWithProviders<TourNgxBootstrapModule> {
    return {
      ngModule: TourNgxBootstrapModule,
      providers: [
        TourStepTemplateService,
        TourService,
        NgxbTourService,
        TourBackdropService
      ]
    };
  }
Example #7
Source File: ino-elements.module.ts    From elements with MIT License 6 votes vote down vote up
static forRoot(
    config?: InoElementsConfig
  ): ModuleWithProviders<InoElementsModule> {
    return {
      ngModule: InoElementsModule,
      providers: [
        {
          provide: ConfigToken,
          useValue: config,
        },
        {
          provide: APP_INITIALIZER,
          useFactory: appInitialize,
          multi: true,
          deps: [ConfigToken, DOCUMENT, NgZone],
        },
      ],
    };
  }
Example #8
Source File: theme.module.ts    From IntelOwl-ng with GNU Affero General Public License v3.0 6 votes vote down vote up
static forRoot(): ModuleWithProviders<ThemeModule> {
    return {
      ngModule: ThemeModule,
      providers: [
        ...NbThemeModule.forRoot(
          {
            name: ThemeSwitcherComponent.getThemeName(),
          },
          [DEFAULT_THEME, DARK_THEME]
        ).providers,
      ],
    };
  }
Example #9
Source File: dashboard.module.ts    From angular-dream-stack with MIT License 6 votes vote down vote up
static forRoot(
    productionBuild: boolean
  ): ModuleWithProviders<DashboardModule> {
    return {
      ngModule: DashboardModule,
      providers: [
        {
          provide: AVAILABLE_APPS,
          useFactory: () => {
            return AvailableApps(productionBuild).reduce(
              (acc, appRegistration) => ({
                ...acc,
                [appRegistration.name]: appRegistration,
              }),
              {}
            );
          },
        },
      ],
    };
  }
Example #10
Source File: dyn-forms-bootstrap.module.ts    From open-source with MIT License 6 votes vote down vote up
static forFeature(): ModuleWithProviders<DynFormsBootstrapModule> {
    return {
      ngModule: DynFormsBootstrapModule,
      providers: getModuleProviders({
        controls: [
          {
            control: DynBsCheckboxComponent.dynControl,
            instance: DynBsCheckboxComponent.dynInstance,
            component: DynBsCheckboxComponent,
          },
          {
            control: DynBsInputComponent.dynControl,
            instance: DynBsInputComponent.dynInstance,
            component: DynBsInputComponent,
          },
          {
            control: DynBsRadioComponent.dynControl,
            instance: DynBsRadioComponent.dynInstance,
            component: DynBsRadioComponent,
          },
          {
            control: DynBsSelectComponent.dynControl,
            instance: DynBsSelectComponent.dynInstance,
            component: DynBsSelectComponent,
          },
        ],
      }),
    };
  }
Example #11
Source File: ng-bootstrap.module.ts    From ngx-ui-tour with MIT License 6 votes vote down vote up
public static forRoot(): ModuleWithProviders<TourNgBootstrapModule> {
    return {
      ngModule: TourNgBootstrapModule,
      providers: [
        TourStepTemplateService,
        TourService,
        NgbTourService,
        TourBackdropService
      ],
    };
  }
Example #12
Source File: theme.module.ts    From digital-bank-ui with Mozilla Public License 2.0 6 votes vote down vote up
static forRoot(): ModuleWithProviders<ThemeModule> {
    return {
      ngModule: ThemeModule,
      providers: [
        ...NbThemeModule.forRoot(
          {
            name: 'default',
          },
          [ DEFAULT_THEME, COSMIC_THEME, CORPORATE_THEME, DARK_THEME, MATERIAL_LIGHT_THEME, MATERIAL_DARK_THEME ],
        ).providers,
      ],
    };
  }
Example #13
Source File: error-report.module.ts    From ionic-pwa-example-moment with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<ErrorReportModule> {
    return {
      ngModule: ErrorReportModule,
      providers: [
        {
          provide: ErrorHandler,
          useValue: Sentry.createErrorHandler(),
        },
        {
          provide: Sentry.TraceService,
          deps: [Router],
        },
        {
          provide: APP_INITIALIZER,
          // eslint-disable-next-line @typescript-eslint/no-empty-function
          useFactory: () => () => {},
          deps: [Sentry.TraceService],
          multi: true,
        },
      ],
    };
  }
Example #14
Source File: ngxs-interceptor.plugin.ts    From detection-app with MIT License 6 votes vote down vote up
static forRoot(config?: any): ModuleWithProviders<NgxsInterceptorPluginModule> {
    return {
      ngModule: NgxsInterceptorPluginModule,
      providers: [
        {
          provide: NGXS_PLUGINS,
          useClass: NgxsInterceptorPlugin,
          multi: true
        },
        {
          provide: NGXS_INTERCEPTOR_PLUGIN_OPTIONS,
          useValue: config
        }
      ]
    };
  }
Example #15
Source File: facet.module.ts    From sba-angular with MIT License 6 votes vote down vote up
public static forRoot(allFacets: any[]|undefined = undefined, defaultFacets: FacetState[]|undefined = undefined): ModuleWithProviders<BsFacetModule> {
        return {
            ngModule: BsFacetModule,
            providers: [
                {
                    provide: ALL_FACETS,
                    useValue: allFacets
                },
                {
                    provide: DEFAULT_FACETS,
                    useValue: defaultFacets
                },
            ]
        };
    }
Example #16
Source File: utility.module.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static forRoot(): ModuleWithProviders {
    return {
      ngModule: UtilityModule,

      providers: []
    };
  }
Example #17
Source File: twirp.module.ts    From protobuf-ts with Apache License 2.0 6 votes vote down vote up
public static forRoot(twirpOptions: TwirpOptions): ModuleWithProviders<TwirpModule> {
    return {
      ngModule: TwirpModule,
      providers: [
        {provide: TWIRP_TRANSPORT_OPTIONS, useValue: twirpOptions},
        {provide: RPC_TRANSPORT, useExisting: TwirpTransport}
      ]
    };
  }
Example #18
Source File: ngx-mat-timepicker.module.ts    From ngx-mat-timepicker with MIT License 6 votes vote down vote up
static setLocale(locale: string): ModuleWithProviders<NgxMatTimepickerModule> {
        return {
            ngModule: NgxMatTimepickerModule,
            providers: [
                {provide: NGX_MAT_TIMEPICKER_LOCALE, useValue: locale},
                {provide: NGX_MAT_TIMEPICKER_CONFIG, useValue: undefined},
            ]
        };
    }
Example #19
Source File: index.ts    From nativescript-plugins with Apache License 2.0 6 votes vote down vote up
static forRoot(url: string, options: SocketIOOptions = {}): ModuleWithProviders<SocketIOModule> {
        return {
            ngModule: SocketIOModule,
            providers: [
                {
                    provide: SocketIO,
                    useFactory: socketIOFactory,
                    deps: [SOCKETIO_URL, SOCKETIO_OPTIONS]
                },
                { provide: SOCKETIO_URL, useValue: url },
                { provide: SOCKETIO_OPTIONS, useValue: options },
            ]
        };
    }
Example #20
Source File: core.module.ts    From ngx-admin-dotnet-starter with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<CoreModule> {
    return {
      ngModule: CoreModule,
      providers: [
        ...NB_CORE_PROVIDERS,
        UserStore,
        UsersService,
        InitUserService,
        SettingsService,
      ],
    };
  }
Example #21
Source File: auth-store.module.ts    From svvs with MIT License 6 votes vote down vote up
static forRoot(options: Partial<IAuthStoreOptions> = {}): ModuleWithProviders<AuthStoreModule> {
    return {
      ngModule: AuthStoreModule,
      providers: [
        {
          provide: HTTP_INTERCEPTORS,
          useClass: AuthInterceptor,
          multi: true
        },
        {
          provide: IAuthFacade,
          useClass: options.facade || BaseAuthFacade
        },
        {
          provide: IAuthStorage,
          useClass: options.storage || BaseAuthStorage
        },
        {
          provide: IAuthApollo,
          useClass: options.apollo || BaseAuthApollo
        }
      ]
    }
  }
Example #22
Source File: dynamic-browser-title.module.ts    From nghacks with MIT License 6 votes vote down vote up
public static forRoot(dynamicBrowserTitleConfig: DynamicBrowserTitleConfig): ModuleWithProviders<DynamicBrowserTitleModule> {
    return {
      ngModule: DynamicBrowserTitleModule,
      providers: [
        {
          provide: DynamicBrowserTitleConfig,
          useValue: dynamicBrowserTitleConfig
        },
      ]
    };
  }
Example #23
Source File: dynamicHooks.m.ts    From ngx-dynamic-hooks with MIT License 6 votes vote down vote up
// Make sure to set the optional function signature "ModuleWithProviders<T>".
  // Note: This will break Angular 5 backwards compatibility, but enable compatibility with newer versions (13+?).
  static forRoot(globalSettings: DynamicHooksGlobalSettings, platformService?: Type<PlatformService>): ModuleWithProviders<DynamicHooksModule> {
    return {
      ngModule: DynamicHooksModule,
      providers: [
        // Put app-wide services here
        { provide: DYNAMICHOOKS_GLOBALSETTINGS, useValue: globalSettings },
        OutletService,
        DataTypeEncoder,
        DataTypeParser,
        DeepComparer,
        HookFinder,
        { provide: PlatformService, useClass: platformService || PlatformBrowserService }
      ]
    };
  }
Example #24
Source File: auth.module.ts    From ngx-admin-dotnet-starter with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<AuthModule> {
    return {
      ngModule: AuthModule,
      providers: [
        { provide: NB_AUTH_TOKEN_INTERCEPTOR_FILTER, useValue: filterInterceptorRequest },
        { provide: HTTP_INTERCEPTORS, useClass: NbAuthJWTInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
        ...GUARDS],
    };
  }
Example #25
Source File: feature-toggle.module.ts    From canopy with Apache License 2.0 6 votes vote down vote up
static forRoot(
    toggles: LgToggles,
    optionsInjectable?: LgFeatureToggleOptions,
  ): ModuleWithProviders<LgFeatureToggleModule> {
    return {
      ngModule: LgFeatureToggleModule,
      providers: [
        LgFeatureToggleService,
        {
          provide: togglesInjectable,
          useFactory: toggles.useFactory,
          deps: toggles.deps,
        },
        {
          provide: togglesOptionsInjectable,
          useValue: optionsInjectable,
        },
      ],
    };
  }
Example #26
Source File: fire-admin.module.ts    From FireAdmin with MIT License 6 votes vote down vote up
static initialize(firebaseConfig: FirebaseOptions): ModuleWithProviders {
    return {
      ngModule: FireAdminModule,
      providers: [
        FireAdminService,
        {
          provide: FirebaseOptionsToken,
          useValue: firebaseConfig
        }
      ]
    };
  }
Example #27
Source File: ecommerce-mock.module.ts    From ngx-admin-dotnet-starter with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<EcommerceMockModule> {
    return {
      ngModule: EcommerceMockModule,
      providers: [
        ...INTERNAL_SERVICES,
        ...SERVICES,
      ],
    };
  }
Example #28
Source File: core.module.ts    From dating-client with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<CoreModule> {
    return {
      ngModule: CoreModule,
      providers: [
        ErrorInterceptorProvider,
        AuthInterceptorProvider,
        // { provide: ErrorHandler, useClass: MyErrorHandler }
      ]
    };
  }
Example #29
Source File: theme.module.ts    From ngx-admin-dotnet-starter with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<ThemeModule> {
    return {
      ngModule: ThemeModule,
      providers: [
        ...NbThemeModule.forRoot(
          {
            name: 'default',
          },
          [ DEFAULT_THEME, COSMIC_THEME, CORPORATE_THEME, DARK_THEME ],
        ).providers,
        InitUserService,
      ],
    };
  }