Dev05
Dev05

Reputation: 90

Angular 6: Disable dynamic checkbox based on condition

I have a dynamic form with repeated checkbox list. Please see https://stackblitz.com/edit/angular-5jdnb5

If a checkbox option is checked in one checkbox list, the same option has to be disabled in other lists. For example, if option Life is checked in first list, the Life checkbox should be disabled in other lists.

How do i implement the logic. Please suggest.

Upvotes: 2

Views: 5016

Answers (2)

Saksham
Saksham

Reputation: 9380

I have created a simpliifed demo HERE which can be understood by mass audience.

The main concept here is to maintain an object of options and the corresponding list id which is used to maintain which list option to disable.

No need to pass data between components, just simple object manipulation on the component template to enable/disable checkboxes

Upvotes: 0

Muhammet Can TONBUL
Muhammet Can TONBUL

Reputation: 3538

You simply need to report this to the top page every time the checkbox's content changes. It's a good solution to communicate with events for this reporting process. Below is the corrected and running application you want. I'm going to edit my answer later.

https://stackblitz.com/edit/angular-bzqbeq

Upvotes: 1

Related Questions