Skip to content

Commit fd28e4b

Browse files
committed
Instead of defining the disabled getter/setter yourself, you can include it via mixin.
1 parent 2bed32a commit fd28e4b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib/list/selection-list.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ import {Subscription} from 'rxjs/Subscription';
3030
import {SPACE} from '../core/keyboard/keycodes';
3131
import {Focusable} from '../core/a11y/focus-key-manager';
3232
import {MdListOption} from './list-option';
33+
import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled';
34+
35+
export class MdSelectionListBase {}
36+
export const _MdSelectionListMixinBase = mixinDisabled(MdSelectionListBase);
3337

3438
@Component({
3539
moduleId: module.id,
3640
selector: 'md-selection-list, mat-selection-list',
41+
inputs: ['disabled'],
3742
host: {
3843
'role': 'listbox',
3944
'[attr.tabindex]': '_tabIndex',
@@ -46,11 +51,10 @@ import {MdListOption} from './list-option';
4651
encapsulation: ViewEncapsulation.None,
4752
changeDetection: ChangeDetectionStrategy.OnPush
4853
})
49-
export class MdSelectionList implements AfterContentInit, OnDestroy {
54+
export class MdSelectionList extends _MdSelectionListMixinBase
55+
implements Focusable, CanDisable, AfterContentInit, OnDestroy {
5056
private _disableRipple: boolean = false;
5157

52-
private _disabled: boolean = false;
53-
5458
/** Tab index for the selection-list. */
5559
_tabIndex = 0;
5660

@@ -83,12 +87,9 @@ export class MdSelectionList implements AfterContentInit, OnDestroy {
8387
get disableRipple() { return this._disableRipple; }
8488
set disableRipple(value: boolean) { this._disableRipple = coerceBooleanProperty(value); }
8589

86-
/** Whether the selection-list is disabled */
87-
@Input()
88-
get disabled() { return this._disabled; }
89-
set disabled(value: any) { this._disabled = coerceBooleanProperty(value); }
90-
91-
constructor(private _element: ElementRef) { }
90+
constructor(private _element: ElementRef) {
91+
super();
92+
}
9293

9394
ngAfterContentInit(): void {
9495
this._keyManager = new FocusKeyManager(this.options).withWrap();

0 commit comments

Comments
 (0)