本文整理汇总了TypeScript中angular2/di.Injector.createChild方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector.createChild方法的具体用法?TypeScript Injector.createChild怎么用?TypeScript Injector.createChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/di.Injector
的用法示例。
在下文中一共展示了Injector.createChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should create child injectors without default bindings", function() {
var parent = new Injector([], {defaultBindings: true});
var child = parent.createChild([]);
var childCar = child.get(Car);
var parentCar = parent.get(Car);
expect(childCar).toBe(parentCar);
});
示例2: _createAppInjector
function _createAppInjector(appComponentType, bindings, zone) {
if (isBlank(_rootInjector))
_rootInjector = new Injector(_rootBindings);
var mergedBindings = isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) : _injectorBindings(appComponentType);
ListWrapper.push(mergedBindings, bind(VmTurnZone).toValue(zone));
return _rootInjector.createChild(mergedBindings);
}
示例3: hostShadowInjectors
function hostShadowInjectors(hostBindings, shadowBindings, hostPreBuildObjects = null) {
if (isBlank(hostPreBuildObjects))
hostPreBuildObjects = defaultPreBuiltObjects;
var inj = new Injector([]);
var shadowInj = inj.createChild([]);
var protoParent = new ProtoElementInjector(null, 0, hostBindings, true);
var host = protoParent.instantiate(null, null);
host.instantiateDirectives(inj, shadowInj, hostPreBuildObjects);
var protoChild = new ProtoElementInjector(protoParent, 0, shadowBindings, false, 1);
var shadow = protoChild.instantiate(null, host);
shadow.instantiateDirectives(shadowInj, null, null);
return shadow;
}
示例4: createTestInjector
export function createTestInjector(bindings) {
var rootInjector = new Injector(_getRootBindings());
return rootInjector.createChild(ListWrapper.concat(_getAppBindings(), bindings));
}