I'm having an issue where in some situations I need to remove the ng-click="" attribute completely from an element depending on a few scenarios. I'm struggling to figure out how to remove the event listener after I remove the ngClick attribute. Even though the ngClick is removed, the event listener is still on that element and executes the ng-click regardless if it isn't even there.
I'm removing the ngClick attribute in a "link" AngularJS directive. Any idea what I should do?
您可以维护一个标志isClickEnabled
表示启用或禁用ng-click
。
ng-click="isClickEnabled && callMyMethod()"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.