Angular应用input和div标签页的动态创建场景
时间:2022-07-26
本文章向大家介绍Angular应用input和div标签页的动态创建场景,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
index.html:
- modulesToDom
- addStyle
- insertStyleElement
把创建好的style添加到head节点去:
Component HTML:
<input [value]= "userInput"/>
和SAP BSP渲染html差不多:
/**
* Creates an empty element using {@link elementStart} and {@link elementEnd}
*
* @codeGenApi
* @param {?} index Index of the element in the data array
* @param {?} name Name of the DOM Node
* @param {?=} attrsIndex Index of the element's attributes in the `consts` array.
* @param {?=} localRefsIndex Index of the element's local references in the `consts` array.
*
* @return {?}
*/
function ɵɵelement(index, name, attrsIndex, localRefsIndex) {
ɵɵelementStart(index, name, attrsIndex, localRefsIndex);
ɵɵelementEnd();
}
/**
* Create DOM element. The instruction must later be followed by `elementEnd()` call.
*
* @codeGenApi
* @param {?} index Index of the element in the LView array
* @param {?} name Name of the DOM Node
* @param {?=} attrsIndex Index of the element's attributes in the `consts` array.
* @param {?=} localRefsIndex Index of the element's local references in the `consts` array.
*
* Attributes and localRefs are passed as an array of strings where elements with an even index
* hold an attribute name and elements with an odd index hold an attribute value, ex.:
* ['id', 'warning5', 'class', 'alert']
*
* @return {?}
*/
function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
/** @type {?} */
const lView = getLView();
/** @type {?} */
const tView = getTView();
/** @type {?} */
const adjustedIndex = HEADER_OFFSET + index;
ngDevMode &&
assertEqual(getBindingIndex(), tView.bindingStartIndex, 'elements should be created before any bindings');
ngDevMode && ngDevMode.rendererCreateElement++;
ngDevMode && assertDataInRange(lView, adjustedIndex);
/** @type {?} */
const renderer = lView[RENDERER];
/** @type {?} */
const native = lView[adjustedIndex] = elementCreate(name, renderer, getNamespace());
/** @type {?} */
const tNode = tView.firstCreatePass ?
elementStartFirstCreatePass(index, tView, lView, native, name, attrsIndex, localRefsIndex) :
(/** @type {?} */ (tView.data[adjustedIndex]));
setPreviousOrParentTNode(tNode, true);
/** @type {?} */
const mergedAttrs = tNode.mergedAttrs;
if (mergedAttrs !== null) {
setUpAttributes(renderer, native, mergedAttrs);
}
/** @type {?} */
const classes = tNode.classes;
if (classes !== null) {
writeDirectClass(renderer, native, classes);
}
/** @type {?} */
const styles = tNode.styles;
if (styles !== null) {
writeDirectStyle(renderer, native, styles);
}
appendChild(tView, lView, native, tNode);
// any immediate children of a component or template container must be pre-emptively
// monkey-patched with the component view data so that the element can be inspected
// later on using any element discovery utility methods (see `element_discovery.ts`)
if (getElementDepthCount() === 0) {
attachPatchData(native, lView);
}
increaseElementDepthCount();
if (isDirectiveHost(tNode)) {
createDirectivesInstances(tView, lView, tNode);
executeContentQueries(tView, tNode, lView);
}
if (localRefsIndex !== null) {
saveResolvedLocalsInData(lView, tNode);
}
}
core.js->animation.js->platform-browser.js
从core到animation再到platform-browser:
此时input的shadow-root里的div里还没有值:
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 【每日一题】37. Sudoku Solver
- A quick introduction to innodb_ruby (2.对innodb_ruby的简单介绍)
- Webkit 内核初探
- 配置跨域后,框架帮我们做了什么?
- python应用(1):安装与使用
- TCP粘包和拆包
- 性能测试必备命令(1)- free
- 记一次有趣的挖矿病毒
- 性能测试必备知识(10)- Linux 是怎么管理内存的?
- Ng-Matero V10 正式发布!
- 30.Python装饰器
- 13-5 vi查找和替换
- 设计模式~适配器模式
- Django model 层之事务管理总结
- 如何在 asp.net core 的中间件中返回具体的页面