Passive Link in Angular 2 - equivalent

后端 未结 16 2754
谎友^
谎友^ 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:30

    That will be same, it doesn't have anything related to angular2. It is simple html tag.

    Basically a(anchor) tag will be rendered by HTML parser.

    Edit

    You can disable that href by having javascript:void(0) on it so nothing will happen on it. (But its hack). I know Angular 1 provided this functionality out of the box which isn't seems correct to me now.

    Test
    

    Plunkr


    Other way around could be using, routerLink directive with passing "" value which will eventually generate blank href=""

    Click me
    

提交回复
热议问题