@angular/core#Provider TypeScript Examples

The following examples show how to use @angular/core#Provider. 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: paginator.directive.spec.ts    From angular-custom-material-paginator with MIT License 6 votes vote down vote up
function createComponent<T>(type: Type<T>, providers: Provider[] = []): ComponentFixture<T> {
  TestBed.configureTestingModule({
    imports: [MatPaginatorModule, NoopAnimationsModule],
    declarations: [type, PaginatorDirective],
    providers: [MatPaginatorIntl, ...providers]
  }).compileComponents();
  const fixture = TestBed.createComponent(type);
  fixture.detectChanges();
  return fixture;
}
Example #2
Source File: plugins.ts    From ng-event-plugins with Apache License 2.0 6 votes vote down vote up
NG_EVENT_PLUGINS: Provider[] = [
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: SilentEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: PreventEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: SelfEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: StopEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: ZoneEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: OptionsEventPlugin,
        multi: true,
    },
    {
        provide: EVENT_MANAGER_PLUGINS,
        useClass: BindEventPlugin,
        multi: true,
    },
]
Example #3
Source File: app.module.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
providers: Provider[] = [
  AppVersion,
  Keyboard,
  ScreenOrientation,
  SplashScreen,
  StatusBar,
  FirebaseX,
  { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
  // { provide: RouteReuseStrategy, useClass: CustomRouteReuseStrategy },
  //{ provide: TranslateModule, deps: [TranslationsLoader.loadAllModulesAndMerge("")]}
]
Example #4
Source File: round-progress.config.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
ROUND_PROGRESS_DEFAULTS_PROVIDER: Provider = {
  provide: ROUND_PROGRESS_DEFAULTS,
  useValue: {
    radius: 125,
    animation: 'easeOutCubic',
    animationDelay: null,
    duration: 500,
    stroke: 15,
    color: '#45CCCE',
    background: '#EAEAEA',
    responsive: false,
    clockwise: true,
    semicircle: false,
    rounded: false,
  },
}
Example #5
Source File: universal-providers.ts    From universal with MIT License 6 votes vote down vote up
UNIVERSAL_PROVIDERS: Provider[] = [
    UNIVERSAL_ANIMATION_FRAME,
    UNIVERSAL_CACHES,
    UNIVERSAL_CRYPTO,
    UNIVERSAL_HISTORY,
    UNIVERSAL_LOCAL_STORAGE,
    UNIVERSAL_SESSION_STORAGE,
    UNIVERSAL_LOCATION,
    UNIVERSAL_MEDIA_DEVICES,
    UNIVERSAL_NAVIGATOR,
    UNIVERSAL_PERFORMANCE,
    UNIVERSAL_SPEECH_SYNTHESIS,
    UNIVERSAL_USER_AGENT,
    UNIVERSAL_WINDOW,
]
Example #6
Source File: form-component-superclass.ts    From s-libs with MIT License 6 votes vote down vote up
/**
 * Use in the `providers` of a component that implements `ControlValueAccessor` to reduce some boilerplate.
 *
 * ```ts
 * @Component({ providers: [provideValueAccessor(MyFormControl)] }
 * class MyFormControl extends BaseFormControl {
 *   // ...
 * }
 * ```
 */
export function provideValueAccessor(type: Type<any>): Provider {
  return {
    provide: NG_VALUE_ACCESSOR,
    useExisting: type,
    multi: true,
  };
}
Example #7
Source File: mock-error-handler.ts    From s-libs with MIT License 6 votes vote down vote up
/**
   * Convenience method to put in a `provide` array, to override Angular's default error handler. You do not need to use this if you are using {@linkcode AngularContext}, which automatically provides it.
   *
   * ```ts
   * TestBed.configureTestingModule({
   *   providers: [MockErrorHandler.overrideProvider()],
   * });
   * ```
   */
  static overrideProvider(): Provider {
    return { provide: ErrorHandler, useExisting: MockErrorHandler };
  }
Example #8
Source File: module.ts    From slate-angular with MIT License 6 votes vote down vote up
export function configureBasicEditableTestingModule(declarations: any[], entryComponents: any[] = [], providers: Provider[] = []) {
    TestBed.configureTestingModule({
    imports: [
        CommonModule, BrowserModule, SlateModule, FormsModule
    ],
    declarations: [...declarations],
    providers: [
        ...providers
    ],
    teardown: { destroyAfterEach: false }
}).overrideModule(BrowserDynamicTestingModule, {
        set: {
            entryComponents: entryComponents,
        }
    }).compileComponents();
}
Example #9
Source File: error-routing.module.ts    From ng-conf-2020-workshop with MIT License 5 votes vote down vote up
providers: Provider[] = []
Example #10
Source File: module.providers.ts    From open-source with MIT License 5 votes vote down vote up
// utility used by DynFormsModule.forFeature
export function getModuleProviders(args?: DynModuleProviders): Provider[] {
  return [
    {
      provide: DYN_LOG_LEVEL,
      useValue: args?.debug || DynLogLevel.Fatal,
    },
    DynLogDriver,
    DynLogger,
    DynFormRegistry,
    DynFormHandlers,
    DynFormFactory,
    ...args?.providers ?? [],
    ...args?.controls?.map(mapPriority(args?.priority)).map((control) => ({
      provide: DYN_CONTROLS_TOKEN,
      useValue: control,
      multi: true,
    })) ?? [],
    ...args?.errorHandlers?.map(mapPriority(args?.priority)).map((errorHandler) => ({
      provide: DYN_ERROR_HANDLERS_TOKEN,
      useValue: errorHandler,
      multi: true,
    })) ?? [],
    ...args?.functions?.map(mapPriority(args?.priority)).map((fn) => ({
      provide: DYN_FUNCTIONS_TOKEN,
      useValue: fn,
      multi: true,
    })) ?? [],
    ...args?.validators?.map(mapPriority(args?.priority)).map((validator) => ({
      provide: DYN_VALIDATORS_TOKEN,
      useValue: validator,
      multi: true,
    })) ?? [],
    ...args?.asyncValidators?.map(mapPriority(args?.priority)).map((asyncValidator) => ({
      provide: DYN_ASYNCVALIDATORS_TOKEN,
      useValue: asyncValidator,
      multi: true,
    })) ?? [],
    ...args?.matchers?.map(mapPriority(args?.priority)).map((matcher) => ({
      provide: DYN_MATCHERS_TOKEN,
      useValue: matcher,
      multi: true,
    })) ?? [],
    ...args?.conditions?.map(mapPriority(args?.priority)).map((condition) => ({
      provide: DYN_MATCHER_CONDITIONS_TOKEN,
      useValue: condition,
      multi: true,
    })) ?? [],
  ];
}
Example #11
Source File: ngx-mat-timepicker-config.token.ts    From ngx-mat-timepicker with MIT License 5 votes vote down vote up
export function provideNgxMatTimepickerOptions(config: NgxMatTimepickerConfig): Provider[] {
    return [
        {provide: NGX_MAT_TIMEPICKER_CONFIG, useValue: config},
    ];
}