Skip to content

Commit 4fe0ac2

Browse files
Small 'disabled' feature
1 parent 3d98d28 commit 4fe0ac2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h2>Basic Configuration</h2>
2222

2323
<h4>Colors</h4>
2424
p-primary
25-
<ngx-checkbox [configuration]="configurationPrimary" [(ngModel)]="isSelected" name="isSelected"></ngx-checkbox>
25+
<ngx-checkbox [configuration]="configurationPrimary" [disabled]="true" [(ngModel)]="isSelected" name="isSelected"></ngx-checkbox>
2626
p-success
2727
<ngx-checkbox [configuration]="configurationSuccess" [(ngModel)]="isSelected" name="isSelected"></ngx-checkbox>
2828
p-danger

src/app/custom-checkbox/custom-checkbox.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div (click)="toggleCheckbox()" [class]="styleCheckBox">
2-
<input [value]="isSelected" type="checkbox" [checked]="isSelected" />
2+
<input [value]="isSelected" type="checkbox" [checked]="isSelected" [disabled]="disabled" />
33
<div [class]="styleColor">
44
<i [class]="styleIcon" [style.background]="configuration.colorHex" [style.color]="configuration.colorInside"></i>
55
<label></label>

src/app/custom-checkbox/custom-checkbox.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ export class CustomCheckboxComponent implements OnInit, ControlValueAccessor {
4949
// @Input() colorHex ? : string;
5050
// @Input() colorInside ? : string;
5151
@Input() configuration: CustomCheckBoxModel;
52+
@Input() disabled: boolean = false;
5253

5354
isSelected: boolean;
5455
styleCheckBox: String;
5556
styleColor: String;
56-
styleIcon: String;
57+
styleIcon: String;z
5758
constructor() {}
5859

5960
ngOnInit() {
@@ -78,6 +79,7 @@ export class CustomCheckboxComponent implements OnInit, ControlValueAccessor {
7879
ngAfterViewInit() {}
7980

8081
toggleCheckbox() {
82+
if (this.disabled) return;
8183
this.isSelected = !this.isSelected;
8284
this._onChange(this.isSelected);
8385
}

0 commit comments

Comments
 (0)