Ask Your Question

How can one disable radio buttons in Angular 5?

asked 2022-08-17 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-05-01 14:00:00 +0000

scrum gravatar image

To disable a radio button in Angular 5, you can use the disabled attribute. Here's an example:

<input type="radio" name="gender" value="male" [disabled]="isDisabled">

In the above code, the radio button will be disabled if the isDisabled variable is set to true. You can set this variable in your component code.

Alternatively, you can use a FormControl to disable the radio button:

this.myForm = new FormGroup({
  'gender': new FormControl({value: 'male', disabled: true})

In this code, the FormControl is initialized with the disabled property set to true, which will disable the corresponding radio button.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2022-08-17 11:00:00 +0000

Seen: 18 times

Last updated: May 01 '21