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 change what i want is to return the original value when i uncheck the checkbox
- Assistant
To achieve the desired behavior of returning the original value when unchecking the checkbox, you can keep track of the original values in a separate variable and reset the value back to the original when the checkbox is unchecked.
First, add a new property
originalValuesto your component to store the original values: - User
implement that in my code
- Assistant
- User
error TS2339: Property 'originalCode' does not exist on type 'ManageCountryComponent'.
- Assistant
Apologies for the confusion. The error is occurring because the template is trying to access the
originalCodetemplate reference variable, which needs to be defined using theng-templatedirective. Here's the corrected code:<table class="table table-borderless text-custom-fs-16px border-b border-custom-gray2"> <!-- Table headers --> <thead class="bg-custom-orange"> <!-- ... --> </thead> <tbody> <!-- Table rows --> <ng-container *ngFor="let country of filteredCountries; let counter = index; let isOdd = odd"> <tr *ngIf="!isInputRowVisible || !country.selected" [class.even:bg-custom-white-bg]="isOdd" [class.odd:bg-white]="!isOdd" class="border-t border-b"> <td class="w-custom-5% rounded-none text-center"> <input type="checkbox" [(ngModel)]="country.selected" (change)="toggleSelect(country)" /> </td> <td class="w-custom-5% rounded-none text-center"> {{ counter + 1 }} </td> <td class="w-custom-10% rounded-none text-center"> <ng-container *ngIf="country.selected; else originalCode"> <input type="text" [(ngModel)]="country.code" maxlength="10" required/> </ng-container> <ng-template #originalCode> {{ getOriginalValue(country, 'code') }} </ng-template> </td> <!-- ... --> </tr> <!-- ... --> </ng-container> </tbody> </table>