Skip to content

Commit 3abe883

Browse files
committed
chore(slide-toggle): add initial documentation of properties
* Adds a basic documentation of the public properties like in the checkbox component.
1 parent 2168d7c commit 3abe883

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 md-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
@@ -72,25 +72,37 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
7272
// Needs to be public to support AOT compilation (as host binding).
7373
_hasFocus: boolean = false;
7474

75+
/** Name value will be applied to the input element if present */
7576
@Input() name: string = null;
77+
78+
/** A unique id for the slide-toggle input. If none is supplied, it will be auto-generated. */
7679
@Input() id: string = this._uniqueId;
80+
81+
/** Used to specify the tabIndex value for the underlying input element. */
7782
@Input() tabIndex: number = 0;
83+
84+
/** Used to set the aria-label attribute on the underlying input element. */
7885
@Input() ariaLabel: string = null;
86+
87+
/** Used to set the aria-labelledby attribute on the underlying input element. */
7988
@Input() ariaLabelledby: string = null;
8089

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

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

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

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

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

@@ -177,11 +189,13 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
177189
this.disabled = isDisabled;
178190
}
179191

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

198+
/** Whether the slide-toggle is checked. */
185199
@Input()
186200
get checked() {
187201
return !!this._checked;
@@ -194,6 +208,7 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
194208
}
195209
}
196210

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

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

0 commit comments

Comments
 (0)