Angular html property的值如何被更新的

简介: Angular html property的值如何被更新的

html页面里有一个input element,通过语法[(ngModel)]双向绑定到model hero的name字段。image.png

image.png上图的方法负责更新element的property:

/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
/**
 * Update a property on a selected element.
 *
 * Operates on the element selected by index via the {@link select} instruction.
 *
 * If the property name also exists as an input property on one of the element's directives,
 * the component property will be set instead of the element property. This check must
 * be conducted at runtime so child components that add new `@Inputs` don't have to be re-compiled
 *
 * @param propName Name of property. Because it is going to DOM, this is not subject to
 *        renaming as part of minification.
 * @param value New value to write.
 * @param sanitizer An optional function used to sanitize the value.
 * @returns This function returns itself so that it may be chained
 * (e.g. `property('name', ctx.name)('title', ctx.title)`)
 *
 * @codeGenApi
 */

image.png

image.png

相关文章
|
1天前
|
前端开发 JavaScript 开发者
【专栏:HTML与CSS前端技术趋势篇】前端框架(React/Vue/Angular)与HTML/CSS的结合使用
【4月更文挑战第30天】前端框架React、Vue和Angular助力UI开发,通过组件化、状态管理和虚拟DOM提升效率。这些框架与HTML/CSS结合,使用模板语法、样式管理及组件化思想。未来趋势包括框架简化、Web组件标准采用和CSS在框架中角色的演变。开发者需紧跟技术发展,掌握新工具,提升开发效能。
|
6月前
|
缓存 UED
如何删除 Angular SSR 应用 State Transfer 嵌入到 HTML 里的某些字段
如何删除 Angular SSR 应用 State Transfer 嵌入到 HTML 里的某些字段
45 0
|
6月前
|
搜索推荐 API SEO
Angular 服务器端渲染的静态 HTML 变为客户端的动态应用的过程
Angular 服务器端渲染的静态 HTML 变为客户端的动态应用的过程
70 1
|
7月前
|
JavaScript UED
Angular 服务器端渲染场景里,服务器端和客户端渲染出的 HTML 源代码有可能不完全一致
Angular 服务器端渲染场景里,服务器端和客户端渲染出的 HTML 源代码有可能不完全一致
60 0
|
8月前
|
JavaScript 前端开发 API
HTML property 和 attribute 的区别
HTML property 和 attribute 的区别
33 0
|
JavaScript
Angular property binding的学习笔记
https://angular.io/guide/property-binding