Angular input控件的click事件表达式如何被转换成JavaScript函数
源代码:
<button (click)="toggle($event)">隐藏/显示</button>
这个表达式toggle($event),如何被Angular转换成的JavaScript函数呢?
通过调试,找到Angular视图渲染的地方:
renderView和executeTemplate:
下面这个函数就是将表达式转换成Angular JavaScript listener的地方:
/*** Adds an event listener to the current node.** If an output exists on one of the node's directives, it also subscribes to the output* and saves the subscription for later cleanup.** \@codeGenApi* @param {?} eventName Name of the event* @param {?} listenerFn The function to be called when event emits* @param {?=} useCapture Whether or not to use capture in event listener* @param {?=} eventTargetResolver Function that returns global target information in case this listener* should be attached to a global object like window, document or body** @return {?}*/
function ɵɵlistener(eventName, listenerFn, useCapture = false, eventTargetResolver) {/** @type {?} */const lView = getLView();/** @type {?} */const tView = getTView();/** @type {?} */const tNode = getPreviousOrParentTNode();listenerInternal(tView, lView, lView[RENDERER], tNode, eventName, listenerFn, useCapture, eventTargetResolver);return ɵɵlistener;
}
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
Angular input控件的click事件表达式如何被转换成JavaScript函数相关推荐
- Angular input控件的click事件响应处理的调用上下文
自定义指令的路径: C:\Code\SPA\spartacus\projects\storefrontlib\src\cms-structure\page\component\component-wr ...
- 使用button触发FileUpload控件的click事件
点击button触发FileUpload控件的click事件 通过点击button按钮触发FileUpload控件,避免因浏览器不同而导致FileUpload控件样式发生变化,影响页面效果. 注意:需 ...
- 陈年佳酿之 - Winform ListView 控件 double click 事件中获取选中的row与column
背景 最近收到了一个关于以前项目的维护请求,那时的楼主还是刚刚工作的小青年~~~ 项目之前使用的是.net/winform.今天重新打开代码,看着之前在FrameWork2.0下面的代码, 满满的回忆 ...
- 【踩错】解决ajax异步更新后控件的click事件失效的方法
2019-11-14 昨天做了一个在线投票网站,是为研究生院"良师益友"活动准备的. 在其中遇到一个问题,用 ajax 异步更新了导师列表,列表中有"投票"按钮 ...
- 探Button控件的Click事件发生始末
先贴结果图: 点击后: 页面代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="s ...
- C#中combobox 控件属性、事件、方法
http://blog.csdn.net/baggio7095586/article/details/6150075 一 .combobox 属性.事件.方法 公共属性 名称 说明 Accessib ...
- asp.net panel 加html,ASP.NET 页面中动态增加的控件、添加事件
要求:页面上有一个Add按钮,每点击一次该按钮,页面上动态创建一个WebPartZone! 提醒:WebPartZone只能在OnInit或之前才能创建,否则报异常! 大家都知道,按钮的点击事件是在R ...
- 使用Angular可重用Component思路实现一个自带图标(icon)的input控件
参考链接:Angular ng-content and Content Projection: A Complete Guide - How To Use ng-content To Improve ...
- 表达式 控件 html,获取HTML表单控件的UrlEncode字符串表达式
/** * * UrlEncode * http://www.cnitblog.com/9jian/ * * 获取 Input(checkbox,radio,text,password).Tex ...
最新文章
- C++设置每屏显示的行数简易办法
- html5 canvas 画图移动端出现锯齿毛边的解决方法
- ARM NEON 优化
- 深度学习——05、深度学习框架Caffe
- 2020年上半年内容行业版权报告
- Asp.Net IHttpHandler介绍
- win10如何设置任务栏在左侧显示
- Security+ 学习笔记15 非对称密码学
- DreamWeaver CC网页设计与制作
- PKI体系和数字证书
- 正则表达式之Matcher类中group方法
- 实验吧唯快不破writeup
- 奥运比赛电视直播一览表
- 《2022 中小企业快成长之年,上云 选对平台是关键,这次我站华为云》
- loadrunner监控mysql服务性能
- Maven创建聚合项目
- 5.jQuery动画
- leetcode 61 旋转链表 c++
- 李一男/任正非,港湾/华为
- maven私服上传jar包