本文整理汇总了TypeScript中angular2/src/core/di.Injector类的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector类的具体用法?TypeScript Injector怎么用?TypeScript Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Injector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createInjector
export function createInjector(zone: NgZone, bus: MessageBus): Injector {
BrowserDomAdapter.makeCurrent();
_rootBindings.push(bind(NgZone).toValue(zone));
_rootBindings.push(bind(MessageBus).toValue(bus));
var injector: Injector = Injector.resolveAndCreate(_rootBindings);
return injector.resolveAndCreateChild(_injectorBindings());
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:7,代码来源:di_bindings.ts
示例2: createInjector
export function createInjector(zone: NgZone, bus: MessageBus): Injector {
BrowserDomAdapter.makeCurrent();
_rootProviders.push(provide(NgZone, {useValue: zone}));
_rootProviders.push(provide(MessageBus, {useValue: bus}));
var injector: Injector = Injector.resolveAndCreate(_rootProviders);
return injector.resolveAndCreateChild(_injectorProviders());
}
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:7,代码来源:di_bindings.ts
示例3: initializeGenericWorkerRenderer
export function initializeGenericWorkerRenderer(injector: Injector) {
var bus = injector.get(MessageBus);
let zone = injector.get(NgZone);
bus.attachToZone(zone);
zone.run(() => {
WORKER_RENDER_MESSAGING_PROVIDERS.forEach((token) => { injector.get(token).start(); });
});
}
开发者ID:17shiooo,项目名称:angular2-learing,代码行数:9,代码来源:worker_render_common.ts
示例4: initWebWorkerApplication
function initWebWorkerApplication(injector: Injector): void {
var scriptUri: string;
try {
scriptUri = injector.get(WORKER_SCRIPT);
} catch (e) {
throw new BaseException(
"You must provide your WebWorker's initialization script with the WORKER_SCRIPT token");
}
let instance = injector.get(WebWorkerInstance);
spawnWebWorker(scriptUri, instance);
initializeGenericWorkerRenderer(injector);
}
开发者ID:0oAimZo0,项目名称:Angular2Learning,代码行数:14,代码来源:worker_render.ts
示例5: create
/**
* Creates a new component.
*/
create(injector: Injector, projectableNodes: any[][] = null,
rootSelectorOrNode: string | any = null): ComponentRef {
var vu: ViewUtils = injector.get(ViewUtils);
if (isBlank(projectableNodes)) {
projectableNodes = [];
}
// Note: Host views don't need a declarationAppElement!
var hostView = this._viewFactory(vu, injector, null);
var hostElement = hostView.create(EMPTY_CONTEXT, projectableNodes, rootSelectorOrNode);
return new ComponentRef_(hostElement, this._componentType);
}
开发者ID:844496869,项目名称:angular,代码行数:14,代码来源:component_factory.ts
示例6: hydrateViewInContainer
hydrateViewInContainer(parentView: viewModule.AppView, boundElementIndex: number,
contextView: viewModule.AppView, contextBoundElementIndex: number,
index: number, imperativelyCreatedProviders: ResolvedProvider[]) {
if (isBlank(contextView)) {
contextView = parentView;
contextBoundElementIndex = boundElementIndex;
}
var viewContainer = parentView.viewContainers[boundElementIndex];
var view = viewContainer.views[index];
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
var injector = isPresent(imperativelyCreatedProviders) ?
Injector.fromResolvedProviders(imperativelyCreatedProviders) :
null;
this._hydrateView(view, injector, elementInjector.getHost(), contextView.context,
contextView.locals);
}
开发者ID:beta3000,项目名称:hola-angular2,代码行数:17,代码来源:view_manager_utils.ts
示例7: 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 = Injector.resolveAndCreate([
sampleBindings, bind(Options.CAPABILITIES).toValue(capabilities),
bind(Options.USER_AGENT).toValue(userAgent),
provide(WebDriverAdapter, {useValue: adapter})
]);
var sampler = injector.get(Sampler);
return sampler.sample();
});
开发者ID:LordBinary,项目名称:angular,代码行数:18,代码来源:runner.ts
示例8: sample
sample({id, execute, prepare, microMetrics, bindings}:
{id: string, execute?: any, prepare?: any, microMetrics?: any, bindings?: any}):
Promise<SampleState> {
var sampleBindings = [
_DEFAULT_PROVIDERS,
this._defaultBindings,
bind(Options.SAMPLE_ID).toValue(id),
bind(Options.EXECUTE).toValue(execute)
];
if (isPresent(prepare)) {
sampleBindings.push(bind(Options.PREPARE).toValue(prepare));
}
if (isPresent(microMetrics)) {
sampleBindings.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
}
if (isPresent(bindings)) {
sampleBindings.push(bindings);
}
var inj = Injector.resolveAndCreate(sampleBindings);
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 = Injector.resolveAndCreate([
sampleBindings,
bind(Options.CAPABILITIES).toValue(capabilities),
bind(Options.USER_AGENT).toValue(userAgent),
provide(WebDriverAdapter, {useValue: adapter})
]);
var sampler = injector.get(Sampler);
return sampler.sample();
});
}
开发者ID:1186792881,项目名称:angular,代码行数:44,代码来源:runner.ts
示例9: createTestInjector
export function createTestInjector(bindings: Array<Type | Binding | any[]>): Injector {
var rootInjector = Injector.resolveAndCreate(_getRootBindings());
return rootInjector.resolveAndCreateChild(ListWrapper.concat(_getAppBindings(), bindings));
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:4,代码来源:test_injector.ts
示例10:
var params = ListWrapper.map(this._tokens, (t) => injector.get(t));
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:1,代码来源:test_injector.ts
注:本文中的angular2/src/core/di.Injector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论