本文整理汇总了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;未经允许,请勿转载。 |
请发表评论