本文整理匯總了TypeScript中angular2/angular2.bind函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bind函數的具體用法?TypeScript bind怎麽用?TypeScript bind使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了bind函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: beforeEachBindings
beforeEachBindings(() => [
BaseRequestOptions,
MockBackend,
bind(Http).toFactory((connectionBackend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
return new Http(connectionBackend, defaultOptions);
}, [
MockBackend,
BaseRequestOptions
]),
bind(IconStore).toClass(IconStore, [
Http
])
]);
示例2: beforeEach
beforeEach(() => {
injector = Injector.resolveAndCreate([
BaseRequestOptions,
MockBackend,
bind(Http).toFactory((connectionBackend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
return new Http(connectionBackend, defaultOptions);
}, [
MockBackend,
BaseRequestOptions
]),
bind(IconStore).toClass(IconStore, [
Http
])
]);
backend = injector.get(MockBackend);
store = injector.get(IconStore);
response = new Response({ body: SVG_GLYPH_HTML });
glyph = createGlyphNode();
});
示例3: function
AppRegistry.registerRunnable(appName, function() {
CustomParse5DomAdapter.makeCurrent();
bootstrap(component, [
ReactNativeRenderer,
bind(Renderer).toAlias(ReactNativeRenderer)
].concat(bindings)).then(function(appRef) {
var zone = appRef._injector.get(NgZone)._innerZone;
require('ReactUpdates').batchedUpdates = zone.bind(require('ReactUpdates').batchedUpdates);
});
});
示例4: bind
/// <reference path="../typings/_custom.d.ts" />
import {bind} from 'angular2/angular2';
import {
ChangeDetection,
DynamicChangeDetection,
JitChangeDetection,
PreGeneratedChangeDetection
} from 'angular2/change_detection';
export var jitInjectables = [
bind(ChangeDetection).toClass(JitChangeDetection)
];
export var dynamicInjectables = [
bind(ChangeDetection).toClass(DynamicChangeDetection)
];
export var preGeneratedInjectables = [
bind(ChangeDetection).toClass(PreGeneratedChangeDetection)
];
export var bestChangeDetectionInjectables = [
PreGeneratedChangeDetection.isSupported() ? preGeneratedInjectables :
JitChangeDetection.isSupported() ? jitInjectables : dynamicInjectables
];
示例5: main
export function main() {
return bootstrap(AppCmp, [bind(APP_BASE_HREF).toValue('/angular2/examples/router/ts/reuse')]);
}
示例6: Component
import {Component, View, Directive, bootstrap, bind, NgFor, NgIf} from "angular2/angular2";
class Service {
}
class Service2 {
}
class Cmp {
static annotations: any[];
}
Cmp.annotations = [
Component({
selector: 'cmp',
injectables: [Service, bind(Service2).toValue(null)]
}),
View({
template: '{{greeting}} world!',
directives: [NgFor, NgIf]
}),
Directive({
selector: '[tooltip]',
properties: [
'text: tooltip'
],
hostListeners: {
'onmouseenter': 'onMouseEnter()',
'onmouseleave': 'onMouseLeave()'
}
})
示例7: bootstrap
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_BINDINGS, ROUTER_PRIMARY_COMPONENT} from 'angular2/router';
// import {HTTP_BINDINGS} from 'http/http';
import {OffersComponent} from './components/offers/OffersComponent';
import {CartComponent} from './components/cart/CartComponent';
import {RegistrationComponent} from './components/registration/RegistrationComponent';
import {UsersComponent} from './components/user/UsersComponent';
//import {HotelbookingServiceImpl} from './services/HotelbookingServiceImpl';
@Component({
selector: 'app',
//viewProviders: [HotelbookingService],
templateUrl: './app.html',
encapsulation: ViewEncapsulation.None,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{ path: '/', component: OffersComponent, as: 'Offers' },
{ path: '/cart', component: CartComponent, as: 'Cart' },
{ path: '/registration', component: RegistrationComponent, as: 'Registration' },
{ path: '/users', component: UsersComponent, as: 'Users' },
{ path: '/users/:id', component: UsersComponent, as: 'UserEdit' }
])
class App {}
bootstrap(App, [
ROUTER_BINDINGS,
bind(ROUTER_PRIMARY_COMPONENT).toValue(App)
]);
示例8: isObservable
import {Observable} from "rx";
function isObservable(obs: any): boolean {
return obs && typeof obs.subscribe === "function";
}
class RxStrategy {
createSubscription(async: any, updateLatestValue: any): any {
return async.subscribe(updateLatestValue, (e: Error) => { throw e; });
}
dispose(subscription: any): void { subscription.dispose(); }
onDestroy(subscription: any): void { subscription.dispose(); }
}
let _rxStrategy: RxStrategy = new RxStrategy();
@Pipe({name: "rx"})
export class RxPipe extends AsyncPipe {
constructor(public _ref: ChangeDetectorRef) { super(_ref); }
supports(obs: any): boolean { return isObservable(obs); }
_selectStrategy(obj: Observable<any>): any {
return _rxStrategy;
}
}
export var rxPipeInjectables: Array<any> = [
bind(RxPipe).toValue(RxPipe)
];
示例9: constructor
/// <reference path="../../typings/_custom.d.ts" />
import {bind, Injectable} from 'angular2/angular2';
@Injectable()
export class Message {
message: Array<string>;
constructor() {
this.message = ('TIME FLIES LIKE AN ARROW').split('');
}
}
export var MESSAGE_BINDINGS: Array<any> = [
bind(Message).toClass(Message)
];
示例10: Boolean
import { ShadowDomStrategy, NativeShadowDomStrategy } from 'angular2/render';
import { bind } from 'angular2/angular2';
import { document } from 'angular2/src/facade/browser';
export var supportsNativeShadowDOM: boolean = Boolean(document && document.body && document.body.createShadowRoot);
export var shadowDomInjectables: Array<any> = !supportsNativeShadowDOM ? [] : [
bind(ShadowDomStrategy).toClass(NativeShadowDomStrategy)
];