当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.provide函数代码示例

本文整理汇总了TypeScript中@angular/core.provide函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provide函数的具体用法?TypeScript provide怎么用?TypeScript provide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了provide函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: provide

import {provide} from '@angular/core';

import {t} from '../../test.framework/index';
import {CoreConfigService, ConsoleService, LogService} from '../index';

const providers: any[] = [
  provide(ConsoleService, { useValue: console }),
  LogService
];

export function main() {
  t.describe('core.framework: LogService', () => {
    
    t.be(() => {
      // ensure statics are in default state
      CoreConfigService.RESET();
      // spy
      t.spyOn(console, 'log');
      t.spyOn(console, 'error');
      t.spyOn(console, 'warn');
      t.spyOn(console, 'info');
    });
    
    t.describe('api', () => {
      
      t.bep(() => providers);
      
      t.it('sanity', t.inject([LogService], (log: LogService) => {
        t.e(log.debug).toBeDefined();
        t.e(log.error).toBeDefined();
        t.e(log.warn).toBeDefined();
开发者ID:Bohmaster,项目名称:angular2-nativescript-redux,代码行数:31,代码来源:log.service.spec.ts

示例2: enableProdMode

import {bootstrap} from '@angular/platform-browser-dynamic';
import {provide, enableProdMode} from '@angular/core';
import {HTTP_PROVIDERS, Http } from '@angular/http';
import {APP_ROUTER_PROVIDERS} from './app.routes';
import {AppComponent} from './app.component';
import {AuthHttp, AuthConfig, tokenNotExpired, JwtHelper} from 'angular2-jwt/angular2-jwt';
import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
import 'rxjs/add/operator/map';

enableProdMode();

declare var toast: any;

bootstrap(AppComponent, [
  APP_ROUTER_PROVIDERS,
  HTTP_PROVIDERS,
  TRANSLATE_PROVIDERS,
  provide(AuthConfig, {useValue: new AuthConfig({
    headerName: 'X-AUTH'
  })}),
  provide(AuthHttp, {
    useFactory: (http) => {
      return new AuthHttp(new AuthConfig({
        headerName: 'X-AUTH'
      }), http);
    },
    deps: [Http]
  }),
  AuthHttp
]);
开发者ID:Rambou,项目名称:respond,代码行数:30,代码来源:main.ts

示例3: bootstrap

// Imports for loading & configuring the in-memory web api
import { provide }    from '@angular/core';
import { XHRBackend } from '@angular/http';
// use in memory to fake the server
import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api';
import { InMemoryDataService }               from './in-memory-data.service';

// the usual stuff for bootstraping
import {bootstrap}    from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import {AppComponent} from './app.component';

bootstrap(AppComponent, [
  HTTP_PROVIDERS,
  provide(XHRBackend, { useClass: InMemoryBackendService }), // in-mem server
  provide(SEED_DATA,  { useClass: InMemoryDataService })     // in-mem server data
]);
开发者ID:rdcoder,项目名称:ng2start,代码行数:17,代码来源:main.ts

示例4: enableProdMode

// Imports for loading & configuring the in-memory web api
import { XHRBackend } from '@angular/http';

import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api';
import { Locker, LockerConfig } from 'angular2-locker'

// The usual bootstrapping imports
import { bootstrap } from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { enableProdMode, provide } from '@angular/core';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { AppComponent } from './components/app.component';
import { appRouterProviders } from './app.routes';
enableProdMode();

bootstrap(AppComponent, [
  disableDeprecatedForms(),
  provideForms(),
  appRouterProviders,
  HTTP_PROVIDERS,
  { provide: LocationStrategy, useClass: HashLocationStrategy },
  provide(LockerConfig, {
    useValue: new LockerConfig('superheroApp', Locker.DRIVERS.LOCAL)
  }),
  Locker
]);
开发者ID:dm4562,项目名称:sales-demo,代码行数:27,代码来源:main.ts

示例5: provide

// libs
import {Angulartics2} from 'angulartics2';
import {Angulartics2Segment} from 'angulartics2/src/providers/angulartics2-segment';
import {provideStore} from '@ngrx/store';
import {TranslateService} from 'ng2-translate/ng2-translate';

// app
import {ConsoleService, LogService} from '../core.framework/index';
import {AnalyticsService} from '../analytics.framework/index';
import {AppConfigService, nameListReducer} from '../app.framework/index';
import {MultilingualService, multilingualReducer} from '../i18n.framework/index';
import {NSAngulartics2Segment} from './services/ns-angulartics2-segment.service';
import {NSLogService} from './services/ns-log.service';
// custom i18n language support
MultilingualService.SUPPORTED_LANGUAGES = AppConfigService.SUPPORTED_LANGUAGES;

export const NS_APP_PROVIDERS: any[] = [
  HTTP_PROVIDERS,
  provide(ConsoleService, { useValue: console }),
  provide(LogService, { useClass: NSLogService }),
  provideStore({  
    i18n: multilingualReducer, 
    names: nameListReducer 
  }),
  Angulartics2,
  provide(Angulartics2Segment, { useClass: NSAngulartics2Segment }),
  AnalyticsService,
  TranslateService,
  MultilingualService
];
开发者ID:Atastor,项目名称:angular2-seed-advanced,代码行数:30,代码来源:index.ts

示例6: enableProdMode

ďťż
/// <reference path="../typings/main.d.ts" />

import { bootstrap } from '@angular/platform-browser-dynamic';
import {HashLocationStrategy, APP_BASE_HREF, LocationStrategy} from '@angular/common';
import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
import {bind, provide, enableProdMode} from '@angular/core';
import {HTTP_PROVIDERS} from '@angular/http';

import {AppComponent} from './shared/app.component';


import "rxjs/Rx";
//import {MATERIAL_PROVIDERS} from "ng2-material";

enableProdMode();

bootstrap(AppComponent, [ROUTER_PROVIDERS, bind(LocationStrategy).toClass(HashLocationStrategy), HTTP_PROVIDERS, provide(APP_BASE_HREF, { useValue: '/' })]);
开发者ID:spaeth21,项目名称:Angular2-WeatherApp,代码行数:18,代码来源:main.ts

示例7: bootstrap

/// <reference path="../typings/browser/ambient/es6-shim/index.d.ts" />

import {bootstrap} from '@angular/platform-browser-dynamic';
import {bind, provide} from '@angular/core';
import { LocationStrategy, HashLocationStrategy} from '@angular/common';
import {AppComponent} from './app';
import { disableDeprecatedForms, provideForms } from '@angular/forms';

import {appRouterProviders} from './app.routes';
import {HTTP_PROVIDERS, Http} from '@angular/http';
import {AuthHttp, AuthConfig} from 'angular2-jwt';

bootstrap(AppComponent, [
  HTTP_PROVIDERS,
  appRouterProviders,
	bind(LocationStrategy).toClass(HashLocationStrategy),
  provideForms(),
  provide(AuthConfig, { useFactory: () => {
    return new AuthConfig();
  }}),
  AuthHttp
]).catch((err: any) => console.error(err));
开发者ID:mnitdeed,项目名称:employerreg,代码行数:22,代码来源:boot.ts

示例8: enableProdMode

import { APP_ROUTER_PROVIDERS } from './app.routes';

if (!process.env.isDevelopment) {
  enableProdMode();
}

bootstrap(AppComponent, [
    disableDeprecatedForms(),
    provideForms(),
    APP_ROUTER_PROVIDERS,
    HTTP_PROVIDERS,
    Overlay,
    OverlayContainer,
    provide(ToastrService, {
      useFactory: (overlay: Overlay, injector: Injector) => {
        const customConfig = new ToastrConfig();
        customConfig.positionClass = 'toast-bottom-right';
        return new ToastrService(customConfig, overlay, injector);
      },
      deps: [Overlay, Injector]
    }),
    provide(AuthHttp, {
      useFactory: (http) => {
        return new AuthHttp(new AuthConfig({
          tokenGetter: (() => sessionStorage.getItem('accessToken'))
        }), http);
      },
      deps: [Http]
    })
  ])
  .catch(err => console.error(err));
开发者ID:kjbetz,项目名称:ami-dev,代码行数:31,代码来源:main.ts

示例9: bootstrap

import { APP_BASE_HREF } from '@angular/common';
import { enableProdMode, provide } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { ROUTER_PROVIDERS } from '@angular/router';

import { AppComponent } from './base';

if ('<%= ENV %>' === 'prod') { enableProdMode(); }

/**
 * Bootstraps the application and makes the ROUTER_PROVIDERS and the APP_BASE_HREF available to it.
 * @see https://angular.io/docs/ts/latest/api/platform-browser-dynamic/index/bootstrap-function.html
 */
bootstrap(AppComponent, [
  ROUTER_PROVIDERS,
  provide(APP_BASE_HREF, { useValue: '<%= APP_BASE %>' })
]);

// In order to start the Service Worker located at "./worker.js"
// uncomment this line. More about Service Workers here
// https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
//
// if ('serviceWorker' in navigator) {
//   (<any>navigator).serviceWorker.register('./worker.js').then((registration: any) =>
//       console.log('ServiceWorker registration successful with scope: ', registration.scope))
//     .catch((err: any) =>
//       console.log('ServiceWorker registration failed: ', err));
// }
开发者ID:13812453806,项目名称:SB-Admin-BS4-Angular-2,代码行数:28,代码来源:main.ts

示例10: provide

import { RouterConfig } from '@angular/router';
import { provideRouter, ExtraOptions } from '@angular/router/src/common_router_providers';

import {NSRouterLink} from './ns-router-link';
import {PageRouterOutlet} from './page-router-outlet';
import {NSLocationStrategy} from './ns-location-strategy';
import {NativescriptPlatformLocation} from './ns-platform-location';
import {RouterExtensions} from './router-extensions';

export {routerTraceCategory} from "../trace";
export {PageRoute} from './page-router-outlet';
export {RouterExtensions} from './router-extensions';

export const NS_ROUTER_PROVIDERS: any[] = [
    NSLocationStrategy,
    provide(LocationStrategy, { useExisting: NSLocationStrategy }),

    NativescriptPlatformLocation,
    provide(PlatformLocation, { useClass: NativescriptPlatformLocation }),
    RouterExtensions
];

export const NS_ROUTER_DIRECTIVES: Type[] = [
    NSRouterLink,
    PageRouterOutlet
];

export function nsProvideRouter(config: RouterConfig, opts: ExtraOptions): any[] {
    return [
        ...NS_ROUTER_PROVIDERS,
        ...provideRouter(config, opts) // NOTE: use provideRouter form common_router_providers - it doesnt include BrowserPlatformLocation
开发者ID:spike1292,项目名称:nativescript-angular,代码行数:31,代码来源:ns-router.ts


注:本文中的@angular/core.provide函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。