Skip to content

Commit 75cd73b

Browse files
devversionjelbourn
authored andcommitted
chore(slide-toggle): add initial documentation of properties (#2261)
* Adds a basic documentation of the public properties like in the checkbox component.
1 parent 8ec3a19 commit 75cd73b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/lib/slide-toggle/slide-toggle.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515

1616
<input #input class="md-slide-toggle-input cdk-visually-hidden" type="checkbox"
17-
[id]="getInputId()"
17+
[id]="inputId"
1818
[required]="required"
1919
[tabIndex]="tabIndex"
2020
[checked]="checked"

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,37 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
7373
// Needs to be public to support AOT compilation (as host binding).
7474
_hasFocus: boolean = false;
7575

76+
/** Name value will be applied to the input element if present */
7677
@Input() name: string = null;
78+
79+
/** A unique id for the slide-toggle input. If none is supplied, it will be auto-generated. */
7780
@Input() id: string = this._uniqueId;
81+
82+
/** Used to specify the tabIndex value for the underlying input element. */
7883
@Input() tabIndex: number = 0;
84+
85+
/** Used to set the aria-label attribute on the underlying input element. */
7986
@Input() ariaLabel: string = null;
87+
88+
/** Used to set the aria-labelledby attribute on the underlying input element. */
8089
@Input() ariaLabelledby: string = null;
8190

91+
/** Whether the slide-toggle is disabled. */
8292
@Input()
8393
get disabled(): boolean { return this._disabled; }
8494
set disabled(value) { this._disabled = coerceBooleanProperty(value); }
8595

96+
/** Whether the slide-toggle is required. */
8697
@Input()
8798
get required(): boolean { return this._required; }
8899
set required(value) { this._required = coerceBooleanProperty(value); }
89100

90101
private _change: EventEmitter<MdSlideToggleChange> = new EventEmitter<MdSlideToggleChange>();
102+
/** An event will be dispatched each time the slide-toggle changes its value. */
91103
@Output() change: Observable<MdSlideToggleChange> = this._change.asObservable();
92104

93-
// Returns the unique id for the visual hidden input.
94-
getInputId = () => `${this.id || this._uniqueId}-input`;
105+
/** Returns the unique id for the visual hidden input. */
106+
get inputId(): string { return `${this.id || this._uniqueId}-input`; }
95107

96108
@ViewChild('input') _inputElement: ElementRef;
97109

@@ -178,11 +190,13 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
178190
this.disabled = isDisabled;
179191
}
180192

193+
/** Focuses the slide-toggle. */
181194
focus() {
182195
this._renderer.invokeElementMethod(this._inputElement.nativeElement, 'focus');
183196
this._onInputFocus();
184197
}
185198

199+
/** Whether the slide-toggle is checked. */
186200
@Input()
187201
get checked() {
188202
return !!this._checked;
@@ -195,6 +209,7 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
195209
}
196210
}
197211

212+
/** The color of the slide-toggle. Can be primary, accent, or warn. */
198213
@Input()
199214
get color(): string {
200215
return this._color;
@@ -204,6 +219,7 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
204219
this._updateColor(value);
205220
}
206221

222+
/** Toggles the checked state of the slide-toggle. */
207223
toggle() {
208224
this.checked = !this.checked;
209225
}

0 commit comments

Comments
 (0)