Attaching click to anchor tag in angular

前端 未结 13 1613
臣服心动
臣服心动 2020-12-13 12:02

I am trying to attach click event to anchor tags (coming from ajax) and block the default redirection. How can I do it in angular ?



        
13条回答
  •  有刺的猬
    2020-12-13 12:58

    You just need to add !! before your click method handler call: (click)="!!onGoToPage2()". The !! will prevent the default action from happening by converting the return of your method to a boolean. If it's a void method, then this will become false.

提交回复
热议问题