ɵɵtemplate和ng-template的对应关系

119 阅读1分钟

模板中每个ng-template,会触发函数ɵɵtemplate:

ɵɵtemplate里会自动创建一个comment element,通过方法createComment完成:

ɵɵtemplate函数内部会创建一个comment element.

/**
 * Creates an LContainer for an ng-template (dynamically-inserted view), e.g.
 *
 * <ng-template #foo>
 *    <div></div>
 * </ng-template>
 *
 * @param index The index of the container in the data array
 * @param templateFn Inline template
 * @param decls The number of nodes, local refs, and pipes for this template
 * @param vars The number of bindings for this template
 * @param tagName The name of the container element, if applicable
 * @param attrsIndex Index of template attributes in the `consts` array.
 * @param localRefs Index of the local references in the `consts` array.
 * @param localRefExtractor A function which extracts local-refs values from the template.
 *        Defaults to the current element associated with the local-ref.
 *
 * @codeGenApi
 */

更多Jerry的原创文章,尽在:“汪子熙”: