单击按钮时,<a href=""> event

时间:2018-07-04 23:09:31

标签: javascript html angular

When I click a button in my Angular page it should execute the a href tag first and then execute the buttons onClick function.

<button (click)="invokeFun()"><a href="mylink.com?state=take-back-to-my-link.com">Link</a> </button>

But when I use this code, It takes me to the link and brings me back but onClick function is not invoked.

when I checked Chrome Inspector, I got this error:

Uncaught ReferenceError : invokeFun is not defined at HTMLButtonElement.onclick

However, when I use onClick separately, it works.

1 个答案:

答案 0 :(得分:0)

否,根据W3C的HTML5规范文档,它不是有效的HTML5: 和more

像这样更改代码
HTML:

TestResult

在Compoent中:

createReportContent()