本文整理汇总了TypeScript中angular2/core.Injector.resolve方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector.resolve方法的具体用法?TypeScript Injector.resolve怎么用?TypeScript Injector.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/core.Injector
的用法示例。
在下文中一共展示了Injector.resolve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createBindings
function createBindings(config: OneButtonPresetData): ResolvedBinding[] {
config.buttons = [
{
cssClass: config.okBtnClass,
caption: config.okBtn,
onClick: (modalComponent: MessageModal, $event?: MouseEvent) =>
modalComponent.dialog.close(true)
}
];
return Injector.resolve([
provide(MessageModalContext, {useValue: config})
]);
}
示例2: GetAlertBindings
private GetAlertBindings(alertConfig: AlertConfig) : ResolvedProvider[]{
return Injector.resolve([provide(AlertConfig, {useValue: alertConfig})]);
}
示例3: main
export function main() {
BrowserDomAdapter.makeCurrent();
var iterations = getIntParameter('iterations');
// This benchmark does not use bootstrap and needs to create a reflector
setupReflector();
var bindings = [A, B, C, D, E];
var injector = Injector.resolveAndCreate(bindings);
var D_KEY = Key.get(D);
var E_KEY = Key.get(E);
var childInjector = injector.resolveAndCreateChild([])
.resolveAndCreateChild([])
.resolveAndCreateChild([])
.resolveAndCreateChild([])
.resolveAndCreateChild([]);
var variousProviders = [A, provide(B, {useClass: C}), [D, [E]], provide(F, {useValue: 6})];
var variousProvidersResolved = Injector.resolve(variousProviders);
function getByToken() {
for (var i = 0; i < iterations; ++i) {
injector.get(D);
injector.get(E);
}
}
function getByKey() {
for (var i = 0; i < iterations; ++i) {
injector.get(D_KEY);
injector.get(E_KEY);
}
}
function getChild() {
for (var i = 0; i < iterations; ++i) {
childInjector.get(D);
childInjector.get(E);
}
}
function instantiate() {
for (var i = 0; i < iterations; ++i) {
var child = injector.resolveAndCreateChild([E]);
child.get(E);
}
}
/**
* Creates an injector with a variety of provider types.
*/
function createVariety() {
for (var i = 0; i < iterations; ++i) {
Injector.resolveAndCreate(variousProviders);
}
}
/**
* Same as [createVariety] but resolves providers ahead of time.
*/
function createVarietyResolved() {
for (var i = 0; i < iterations; ++i) {
Injector.fromResolvedProviders(variousProvidersResolved);
}
}
bindAction('#getByToken', () => microBenchmark('injectAvg', iterations, getByToken));
bindAction('#getByKey', () => microBenchmark('injectAvg', iterations, getByKey));
bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild));
bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate));
bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety));
bindAction('#createVarietyResolved',
() => microBenchmark('injectAvg', iterations, createVarietyResolved));
}
示例4: render
private render():void{
this._loader.loadNextToLocation(this._rendererRegistry.getBestComponent(this._uiSchema,this._dataSchema,this._data), this._elementRef,
Injector.resolve([provide('uiSchema', {useValue: this._uiSchema}),provide('data', {useValue: this._data}),provide('dataSchema', {useValue: this._dataSchema})]));
}