如何知道使用chrome开发人员工具是否触发了角度4点击事件?

时间:2018-01-02 22:14:30

标签: angular angular4-forms

我的app.component.html页面中有以下html标记

<a (click)='clicked=0' style='border-style: solid; padding: 5px 50px 5px 50px;' routerLink='/route/show'>Show Details</a>

但是当我在我的chrome中加载此页面并查看chrome开发工具中的html时,它显示在下面

<a routerlink="/route/show" style="border-style: solid; padding: 5px 50px 5px 50px;" ng-reflect-router-link="/route/show" href="#/route/show">Show Details</a>

为什么它没有显示我的(点击)==&#39;点击= 0&#39;在chrome开发人员工具中。有什么我想念它,我使用角4.谢谢。

1 个答案:

答案 0 :(得分:3)

在编译时,(click)事件绑定被转换为事件监听器,并且不再像以下那样可见:

<a (click)='clicked=0' ...

routerLink完全相同的内容会被转换为ng-reflect-router-link

如果你打开开发工具,检查元素,然后打开事件监听器选项卡,你会看到事件已被绑定,你可以追溯到(最有可能)匿名函数已生成以处理clicked = 0