當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.bind函數代碼示例

本文整理匯總了TypeScript中@angular/core.bind函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bind函數的具體用法?TypeScript bind怎麽用?TypeScript bind使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了bind函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: sample

  sample({id, execute, prepare, microMetrics, providers}:
             {id: string, execute?: any, prepare?: any, microMetrics?: any, providers?: any}):
      Promise<SampleState> {
    var sampleProviders = [
      _DEFAULT_PROVIDERS,
      this._defaultProviders,
      bind(Options.SAMPLE_ID).toValue(id),
      bind(Options.EXECUTE).toValue(execute)
    ];
    if (isPresent(prepare)) {
      sampleProviders.push(bind(Options.PREPARE).toValue(prepare));
    }
    if (isPresent(microMetrics)) {
      sampleProviders.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
    }
    if (isPresent(providers)) {
      sampleProviders.push(providers);
    }

    var inj = ReflectiveInjector.resolveAndCreate(sampleProviders);
    var adapter = inj.get(WebDriverAdapter);

    return PromiseWrapper
        .all([adapter.capabilities(), adapter.executeScript('return window.navigator.userAgent;')])
        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = ReflectiveInjector.resolveAndCreate([
            sampleProviders,
            bind(Options.CAPABILITIES).toValue(capabilities),
            bind(Options.USER_AGENT).toValue(userAgent),
            provide(WebDriverAdapter, {useValue: adapter})
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
  }
開發者ID:0xJoKe,項目名稱:angular,代碼行數:44,代碼來源:runner.ts

示例2: bind

        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = ReflectiveInjector.resolveAndCreate([
            sampleProviders,
            bind(Options.CAPABILITIES).toValue(capabilities),
            bind(Options.USER_AGENT).toValue(userAgent),
            provide(WebDriverAdapter, {useValue: adapter})
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
開發者ID:0xJoKe,項目名稱:angular,代碼行數:19,代碼來源:runner.ts

示例3: main

export function main(initialHmrState?: any): Promise<any> {

  return bootstrap(App, [
    // To add more vendor providers please look in the platform/ folder
    ...PLATFORM_PROVIDERS,
    ...ENV_PROVIDERS,
    ...APP_PROVIDERS,
    ...HTTP_PROVIDERS,
    bind(LocationStrategy).toClass(PathLocationStrategy)
  ])
  .then(decorateComponentRef)
  .catch(err => console.error(err));

}
開發者ID:Hu4oCu,項目名稱:loc.ecs.angular,代碼行數:14,代碼來源:main.browser.ts

示例4: bootstrap

import { PatientStore } from './components/state/PatientStore';
import { TreatmentBackendService } from './services/TreatmentBackendService';
import { TreatmentStore } from './components/state/TreatmentStore';
import { UiStateStore } from './components/state/UiStateStore';
bootstrap(AppComponent, [
    ROUTER_PROVIDERS,
//    ROUTER_BINDINGS,
    PatientStore,
    TreatmentStore,
    UiStateStore,
    FORM_PROVIDERS,
    HTTP_PROVIDERS,
    ELEMENT_PROBE_PROVIDERS,
    MATERIAL_PROVIDERS,
    NotificationService,
//    PatientService,
    PatientBackendService,
    TreatmentBackendService,
    provide(AuthHttp, {
      useFactory: (http) => {
        return new AuthHttp(new AuthConfig(), http);
      },
      deps: [Http]
    }),
     provide(APP_BASE_HREF, {useValue : '/' }),
    bind(LocationStrategy).toClass(PathLocationStrategy)
]).then(
    success => console.log('AppComponent bootstrapped!'),
    error => console.log('AppComponent NOT bootstrapped!', error)
);
開發者ID:pmiodrag,項目名稱:dental-dashboard,代碼行數:30,代碼來源:main.ts

示例5: bootstrap

import {bootstrap}        from '@angular/platform-browser-dynamic';
import {HTTP_PROVIDERS} from '@angular/http';
import 'rxjs/Rx';
    
import{ComponentOne} from './component_one';
import{ComponentTwo} from './component_two';
import{CountriesList} from './app.component';
    
@Component({
  selector: 'my-app',
  template: `
    <h1>Component Router</h1>
    <nav>
      <a [routerLink]="['ComponentOne']">Component One</a><hr/>
      <a [routerLink]="['ComponentTwo']">Component Two</a><hr/>
      <a [routerLink]="['CountriesList']">List of countries</a>
    </nav>
    <router-outlet></router-outlet>
  `,
  directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
  {path:'/component-one', name: 'ComponentOne', component: ComponentOne},
  {path:'/component-two', name: 'ComponentTwo', component: ComponentTwo},
  {path:'/countries', name: 'CountriesList', component:CountriesList}
])
export class AppComponent { }
   
    bootstrap(AppComponent, [HTTP_PROVIDERS,
      ROUTER_PROVIDERS,bind(APP_BASE_HREF).toValue(location.pathname)
    ]);
開發者ID:bruno-oliveira,項目名稱:MEAN-repo,代碼行數:31,代碼來源:main.ts

示例6: enableProdMode

import { enableProdMode } from '@angular/core';
import {bind, provide} from '@angular/core';
import { LocationStrategy, HashLocationStrategy} from '@angular/common';
import {AppComponent, environment} from './app';

import {provideForms, disableDeprecatedForms} from '@angular/forms';

import {APP_ROUTER_PROVIDER, AuthGuard} from './app';
import {DataService} from './app/shared';
import {HTTP_PROVIDERS, Http} from '@angular/http';
import {AuthHttp, AuthConfig} from 'angular2-jwt';
import { bootstrap } from '@angular/platform-browser-dynamic';

if (environment.production) {
  enableProdMode();
}

bootstrap(AppComponent, [
  disableDeprecatedForms(),
  provideForms(),
  HTTP_PROVIDERS,
	APP_ROUTER_PROVIDER,
	bind(LocationStrategy).toClass(HashLocationStrategy),
  provide(AuthConfig, { useFactory: () => {
    return new AuthConfig();
  }}),
  AuthHttp,
  AuthGuard,
  DataService
]);
開發者ID:DavyDuDu,項目名稱:ng2_play,代碼行數:30,代碼來源:main.ts

示例7: bootstrap

import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { ROUTER_PROVIDERS} from'@angular/router';
import { AppComponent } from './app.component';
import {bind} from '@angular/core';
import {LocationStrategy, HashLocationStrategy} from '@angular/common';
import { SpinnerService } from './shared/spinner.service';

// enableProdMode();

bootstrap(AppComponent,[ROUTER_PROVIDERS,bind(LocationStrategy).toClass(HashLocationStrategy),SpinnerService])
    .then(success => console.log(`Bootstrap success`))
    .catch(error => console.log(error));
開發者ID:SuperHeros5,項目名稱:Busroutes,代碼行數:13,代碼來源:main.ts

示例8: bootstrap

import {bootstrap} from '@angular/platform-browser-dynamic';
import {AppComponent} from './components/app/app.component'
import {LocationStrategy, HashLocationStrategy} from '@angular/common'
import {bind} from '@angular/core'

bootstrap(AppComponent, [bind(LocationStrategy).toClass(HashLocationStrategy)])
	.then(success => console.log(`Bootstrap success `))
	.catch(error => console.log(error));
開發者ID:informaticslab,項目名稱:sauron,代碼行數:8,代碼來源:bootstrap.ts

示例9: transform

import {Pipe, bind} from '@angular/core';
import * as moment from 'moment';

@Pipe({
  name: 'fromNow'
})
export class FromNowPipe {
  transform(value: any, args: Array<any>): string {
    return moment(value).fromNow();
  }
}

export var fromNowPipeInjectables: Array<any> = [
  bind(FromNowPipe).toValue(FromNowPipe)
];

開發者ID:Angular2-BD,項目名稱:angular2-rxjs-chat,代碼行數:15,代碼來源:FromNowPipe.ts

示例10: constructor

import { Component, Injectable, bind } from '@angular/core';
import { ImageItem, ImageItemComponent } from './image_item';
import {Observable} from 'rxjs/Rx';
import 'rxjs/Rx';

import { 
  Http,
  Response,
  RequestOptions,
  Headers
} from '@angular/http';

@Injectable()
export class ImageService {
    public images: Observable<any>;
    
    constructor(public http: Http ) {
    }
    
    refreshImages(): any
    {
        this.images = this.http.get('http://localhost:8020/get_all_images')
        .map((res:Response) => { return res;})     
        .publishReplay(1).refCount();   
        return this.images;
    }
}

export var imageServiceInjectables: Array<any> = [
  bind(ImageService).toClass(ImageService)
];
開發者ID:radecanak,項目名稱:test-projects,代碼行數:31,代碼來源:image_service.ts


注:本文中的@angular/core.bind函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。