jeudi 3 décembre 2020

Toastr message condition for no of checkboxes clicked angular

I have a Form field named Value.I have a add button which duplicates the form.

I have a table button which shows and a back button to hide the table.

The table has a column that is full of checkboxes. Now in the table, I will click as many checkboxes as the value I entered in the value form. Say for example if I had entered 2 in that form I can click up to 2 checkboxes in that table.

Now what I need is that if I click more checkboxes than the number I entered in the value field I need it to show a toastr message on change. So If the value in that form field is 2, I can only enable 2 checkboxes. Anything more than that should result in toastr error

sample

WHAT I TRIED(OPTIONAL READ)

I used a ngmodel to take value from that form and also added count variable to checkbox click event change function which added itself by 1 and compared these both values for toastr. But that didnt work as count variable got added for every click both enable and disable

I have explained the question as clear as possible. Please comment below if my question is unclear.

Stackblitz link: https://stackblitz.com/edit/angular-ivy-sypjzk?file=src%2Fapp%2Fapp.component.html




Aucun commentaire:

Enregistrer un commentaire