Angular应用input和div标签页的动态创建场景
生活随笔
收集整理的這篇文章主要介紹了
Angular应用input和div标签页的动态创建场景
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
index.html:
- modulesToDom
- addStyle
- insertStyleElement
把創(chuàng)建好的style添加到head節(jié)點去:
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里還沒有值:
要獲取更多Jerry的原創(chuàng)文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的Angular应用input和div标签页的动态创建场景的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Angular应用动态创建style标签
- 下一篇: 苹果手机怎么共享wifi密码给另一个ip