Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 disable click on div

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

like image 200
Mohammad Raheem Avatar asked May 08 '18 13:05

Mohammad Raheem


People also ask

How to disable div in Angular?

Div element cannot be disabled like form controls. You can disable form controls in div instead.

How do I stop a click in HTML?

To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element.


1 Answers

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

like image 140
Lazaro Henrique Avatar answered Sep 21 '22 03:09

Lazaro Henrique