How can I conditionally disable the routerLink attribute?

后端 未结 6 2063
时光取名叫无心
时光取名叫无心 2020-11-27 05:56

In my Angular 2 application I\'m trying to disable a routerLink without any success. I\'ve tried to handle the click event on the click event (with event.

6条回答
  •  粉色の甜心
    2020-11-27 06:37

    Disable pointer-events on the element via CSS:

    Link
    
    a.disabled {
       pointer-events: none;
       cursor: default;
    }
    

    See also Angular2, what is the correct way to disable an anchor element?

    or

    Link
    
    not a link

    or to easily reuse the disabled link template

    
      
    not a link
    Link

提交回复
热议问题