本文整理汇总了TypeScript中angular2/src/render/dom/direct_dom_renderer.DirectDomRenderer类的典型用法代码示例。如果您正苦于以下问题:TypeScript DirectDomRenderer类的具体用法?TypeScript DirectDomRenderer怎么用?TypeScript DirectDomRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DirectDomRenderer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor({urlData,
viewCacheCapacity,
shadowDomStrategy,
templates}) {
this._templates = MapWrapper.create();
if (isPresent(templates)) {
ListWrapper.forEach(templates, (template) => {
MapWrapper.set(this._templates, template.componentId, template);
});
}
this._compileCache = MapWrapper.create();
var parser = new Parser(new Lexer());
var urlResolver = new UrlResolver();
if (isBlank(shadowDomStrategy)) {
shadowDomStrategy = new EmulatedUnscopedShadowDomStrategy(new StyleUrlResolver(urlResolver), null);
}
var compiler = new Compiler(new DefaultStepFactory(parser, shadowDomStrategy), new FakeTemplateLoader(urlResolver, urlData));
if (isBlank(viewCacheCapacity)) {
viewCacheCapacity = 1;
}
if (isBlank(urlData)) {
urlData = MapWrapper.create();
}
this.eventPlugin = new FakeEventManagerPlugin();
var eventManager = new EventManager([this.eventPlugin], new FakeVmTurnZone());
var viewFactory = new ViewFactory(viewCacheCapacity, eventManager, shadowDomStrategy);
this.renderer = new DirectDomRenderer(compiler, viewFactory, shadowDomStrategy);
this.rootEl = el('<div></div>');
this.rootProtoViewRef = this.renderer.createRootProtoView(this.rootEl);
}
示例2: BaseException
_compileRecurse(template) {
var result = MapWrapper.get(this._compileCache, template.componentId);
if (isPresent(result)) {
return result;
}
result = this.renderer.compile(template).then((pv) => {
var childComponentPromises = ListWrapper.map(this._findNestedComponentIds(template, pv), (componentId) => {
var childTemplate = MapWrapper.get(this._templates, componentId);
if (isBlank(childTemplate)) {
throw new BaseException(`Could not find template for ${componentId}!`);
}
return this._compileRecurse(childTemplate);
});
return PromiseWrapper.all(childComponentPromises).then((protoViewRefsWithChildren) => {
var protoViewRefs = ListWrapper.map(protoViewRefsWithChildren, (arr) => arr[0]);
return this._flattenList([this.renderer.mergeChildComponentProtoViews(pv.render, protoViewRefs), protoViewRefsWithChildren]);
});
});
MapWrapper.set(this._compileCache, template.componentId, result);
return result;
}
示例3:
return PromiseWrapper.all(childComponentPromises).then((protoViewRefsWithChildren) => {
var protoViewRefs = ListWrapper.map(protoViewRefsWithChildren, (arr) => arr[0]);
return this._flattenList([this.renderer.mergeChildComponentProtoViews(pv.render, protoViewRefs), protoViewRefsWithChildren]);
});