ng-click still fires when div is (ng)disabled

后端 未结 5 1561
孤街浪徒
孤街浪徒 2021-02-03 20:15

Problem is that ng-click works on so event if cancelTicket === false it still fires ng-click. How can I stop that?

5条回答
  •  忘了有多久
    2021-02-03 20:47

    My solution has been to use an html directive with an attribute used instead of ng-click, so that

    
    

    and the directive defined as follow:

    1) template:

    
    

    2) controller:

    angular.module('module')
    .directive('htmlTagDirective',function() {
        return {
            restrict:'E',
            templateUrl:'template.html',
            scope:{
                disabled:'=',
                click: '&'
            },
            link:function(scope,element){
    
                scope.onClick = function() {
                    if (!(scope.disabled)) {
                        scope.newClick();
                    }
                };
    
            }
        };
    });
    

提交回复
热议问题