when i click the checkbox the row is converted to textbox then when i tried to change…
- User
when i click the checkbox the row is converted to textbox then when i tried to change the data then uncheck the checkbox the value changed what i want is to return the original value when i uncheck the checkbox
- Assistant
The issue you're facing is because you are binding the value in the input fields directly to the
ngModelwithout storing the original value separately. As a result, when the checkbox is unchecked, the modified value is still persisted.To revert back to the original value when the checkbox is unchecked, you need to store the original values of the fields separately. You can achieve this by creating a copy of the country object and using it for editing. Here's how you can modify your code to achieve this:
In your component file, declare a new variable
selectedCountryto store the currently selected country:selectedCountry: any;In the template, update the
(change)event of the checkbox to call atoggleCountrySelection()method:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.