Browse Source

Merge pull request #23027 from abpframework/fix/#19985

Angular - Checkboxes are not checked after clicking their labels.
pull/23061/head
oykuermann 1 year ago
committed by GitHub
parent
commit
830ef4dec6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 18
      npm/ng-packs/packages/components/extensible/src/lib/components/multi-select/extensible-form-multiselect.component.ts

18
npm/ng-packs/packages/components/extensible/src/lib/components/multi-select/extensible-form-multiselect.component.ts

@ -1,8 +1,9 @@
import { Component, ChangeDetectionStrategy, forwardRef, input } from '@angular/core'; import { Component, ChangeDetectionStrategy, forwardRef, input } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor, ReactiveFormsModule } from '@angular/forms'; import { NG_VALUE_ACCESSOR, ControlValueAccessor, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ABP, LocalizationModule } from '@abp/ng.core'; import { ABP, LocalizationPipe } from '@abp/ng.core';
import { FormProp } from '../../models/form-props'; import { FormProp } from '../../models/form-props';
import { NgxValidateCoreModule } from '@ngx-validate/core';
const EXTENSIBLE_FORM_MULTI_SELECT_CONTROL_VALUE_ACCESSOR = { const EXTENSIBLE_FORM_MULTI_SELECT_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR, provide: NG_VALUE_ACCESSOR,
@ -19,21 +20,24 @@ const EXTENSIBLE_FORM_MULTI_SELECT_CONTROL_VALUE_ACCESSOR = {
<input <input
type="checkbox" type="checkbox"
class="form-check-input" class="form-check-input"
[id]="'checkbox_' + option.value"
[disabled]="disabled" [disabled]="disabled"
[checked]="isChecked(option.value)" [checked]="isChecked(option.value)"
(change)="onCheckboxChange(option.value, $event.target.checked)" (change)="onCheckboxChange(option.value, $event.target.checked)"
/> />
@if (prop().isExtra) { <label [for]="'checkbox_' + option.value">
{{ '::' + option.key | abpLocalization }} @if (prop().isExtra) {
} @else { {{ '::' + option.key | abpLocalization }}
{{ option.key }} } @else {
} {{ option.key }}
}
</label>
</div> </div>
} }
</div> </div>
`, `,
providers: [EXTENSIBLE_FORM_MULTI_SELECT_CONTROL_VALUE_ACCESSOR], providers: [EXTENSIBLE_FORM_MULTI_SELECT_CONTROL_VALUE_ACCESSOR],
imports: [LocalizationModule, CommonModule, ReactiveFormsModule], imports: [LocalizationPipe, CommonModule, ReactiveFormsModule, NgxValidateCoreModule],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class ExtensibleFormMultiselectComponent implements ControlValueAccessor { export class ExtensibleFormMultiselectComponent implements ControlValueAccessor {

Loading…
Cancel
Save