Enable/Disable Anchor Tags using AngularJS

后端 未结 11 1596
一整个雨季
一整个雨季 2020-12-01 05:45

How do I enable/disable anchor tags using the directive approach?

Example:

  1. while clicking on edit link, create & delete needs to be disabled or g
11条回答
  •  感情败类
    2020-12-01 06:39

    You may, redefine the a tag using angular directive:

    angular.module('myApp').directive('a', function() {
      return {
        restrict: 'E',
        link: function(scope, elem, attrs) {
          if ('disabled' in attrs) {
            elem.on('click', function(e) {
              e.preventDefault(); // prevent link click
            });
          }
        }
      };
    });
    

    In html:

    Next
    

提交回复
热议问题