Passive Link in Angular 2 - equivalent

后端 未结 16 2814
谎友^
谎友^ 2020-12-04 13:36

In Angular 1.x I can do the following to create a link which does basically nothing:

My Link

But the same tag

16条回答
  •  余生分开走
    2020-12-04 14:27

    You have prevent the default browser behaviour. But you don’t need to create a directive to accomplish that.

    It’s easy as the following example:

    my.component.html

    Link
    

    my.component.ts

    goToPage(pageIndex, event) {
      event.preventDefault();
      console.log(pageIndex);
    }
    

提交回复
热议问题