DEV Community

Cover image for How to disable active and inactive button based on the status?
Akhil Ashok
Akhil Ashok

Posted on

How to disable active and inactive button based on the status?

How to disable active and inactive button based on the status like, if status is pending the button must be disabled and if status is active the button is enabled

Top comments (5)

Collapse
 
jaredcomiso profile image
jaredcomiso

I guess you can bind the disable property of the button and use the ngOnChanges hook to check the status.

Collapse
 
dreamcatcher8055 profile image
Akhil Ashok

sorry i didn't get that

Collapse
 
jaredcomiso profile image
jaredcomiso

you have to bind the button property

Example:

Then in your ts create a variable isDisabled with type boolean so it can either be true or false.
Then include an onChanges hooks(like onInit).
Then inside the hook function you can do the cases
example:

if(status === 'pending') {
this.isDisabled = true;
}

Collapse
 
md_loveluislam_cd3941b23 profile image
MD Lovelu Islam

666

Collapse
 
md_loveluislam_cd3941b23 profile image
MD Lovelu Islam

B666