@@ -10,6 +10,7 @@ import {
10
10
ViewEncapsulation
11
11
} from '@angular/core' ;
12
12
import { coerceBooleanProperty , FocusOriginMonitor } from '../core' ;
13
+ import { mixinDisabled , CanDisable } from '../core/common-behaviors/disabled' ;
13
14
14
15
15
16
// TODO(kara): Convert attribute selectors to classes when attr maps become available
@@ -79,6 +80,11 @@ export class MdFabCssMatStyler {}
79
80
export class MdMiniFabCssMatStyler { }
80
81
81
82
83
+ // Boilerplate for applying mixins to MdButton.
84
+ export class MdButtonBase { }
85
+ export const _MdButtonMixinBase = mixinDisabled ( MdButtonBase ) ;
86
+
87
+
82
88
/**
83
89
* Material design button.
84
90
*/
@@ -89,14 +95,15 @@ export class MdMiniFabCssMatStyler {}
89
95
'button[mat-button], button[mat-raised-button], button[mat-icon-button],' +
90
96
'button[mat-fab], button[mat-mini-fab]' ,
91
97
host : {
92
- '[disabled]' : 'disabled' ,
98
+ '[disabled]' : 'disabled || null ' ,
93
99
} ,
100
+ inputs : [ 'disabled' ] ,
94
101
templateUrl : 'button.html' ,
95
102
styleUrls : [ 'button.css' ] ,
96
103
encapsulation : ViewEncapsulation . None ,
97
104
changeDetection : ChangeDetectionStrategy . OnPush ,
98
105
} )
99
- export class MdButton implements OnDestroy {
106
+ export class MdButton extends _MdButtonMixinBase implements OnDestroy , CanDisable {
100
107
private _color : string ;
101
108
102
109
/** Whether the button is round. */
@@ -107,20 +114,15 @@ export class MdButton implements OnDestroy {
107
114
108
115
/** Whether the ripple effect on click should be disabled. */
109
116
private _disableRipple : boolean = false ;
110
- private _disabled : boolean = null ;
111
117
112
118
/** Whether the ripple effect for this button is disabled. */
113
119
@Input ( )
114
120
get disableRipple ( ) { return this . _disableRipple ; }
115
121
set disableRipple ( v ) { this . _disableRipple = coerceBooleanProperty ( v ) ; }
116
122
117
- /** Whether the button is disabled. */
118
- @Input ( )
119
- get disabled ( ) { return this . _disabled ; }
120
- set disabled ( value : boolean ) { this . _disabled = coerceBooleanProperty ( value ) ? true : null ; }
121
-
122
123
constructor ( private _elementRef : ElementRef , private _renderer : Renderer ,
123
124
private _focusOriginMonitor : FocusOriginMonitor ) {
125
+ super ( ) ;
124
126
this . _focusOriginMonitor . monitor ( this . _elementRef . nativeElement , this . _renderer , true ) ;
125
127
}
126
128
@@ -179,10 +181,11 @@ export class MdButton implements OnDestroy {
179
181
selector : `a[md-button], a[md-raised-button], a[md-icon-button], a[md-fab], a[md-mini-fab],
180
182
a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]` ,
181
183
host : {
182
- '[attr.disabled]' : 'disabled' ,
184
+ '[attr.disabled]' : 'disabled || null ' ,
183
185
'[attr.aria-disabled]' : '_isAriaDisabled' ,
184
186
'(click)' : '_haltDisabledEvents($event)' ,
185
187
} ,
188
+ inputs : [ 'disabled' ] ,
186
189
templateUrl : 'button.html' ,
187
190
styleUrls : [ 'button.css' ] ,
188
191
encapsulation : ViewEncapsulation . None
0 commit comments