Angular2 disable click on div

Mohammad Raheem picture Mohammad Raheem · May 8, 2018 · Viewed 8.1k times · Source

I tried lots and search numbers of time but I didnt get any solution to disable click on div element. Already question has been asked but they are saying not possible on divs and I want to know only, is there any ways to disable div in angular2

<div>(click)="isDisabled ? $event.stopPropagation() : myClickHandler($event); isDisabled ? false : null"
   [class.isDisabled]="isDisabled"></div>

And the old answer not clearly about disabling divs and pointer-events:none is not supported in old version browser also it become editable from network tab

Answer

Lazaro Henrique picture Lazaro Henrique · May 8, 2018

You can use css:

pointer-events:none

Or maybe could do something like:

<div (click)="false; $event.stopPropagation();"> </div>

There are several ways of preventing a click, depends on what you need