File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import {Component, DebugElement} from '@angular/core';
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { ViewportRuler } from '@angular/cdk/scrolling' ;
5
5
import { FakeViewportRuler } from '@angular/cdk/testing' ;
6
- import { MatButtonModule } from './index' ;
6
+ import { MatButtonModule , MatButton } from './index' ;
7
7
import { MatRipple } from '@angular/material/core' ;
8
8
9
9
@@ -46,6 +46,13 @@ describe('MatButton', () => {
46
46
expect ( aDebugElement . nativeElement . classList ) . not . toContain ( 'mat-accent' ) ;
47
47
} ) ;
48
48
49
+ it ( 'should expose the ripple instance' , ( ) => {
50
+ const fixture = TestBed . createComponent ( TestApp ) ;
51
+ const button = fixture . debugElement . query ( By . css ( 'button' ) ) . componentInstance as MatButton ;
52
+
53
+ expect ( button . ripple ) . toBeTruthy ( ) ;
54
+ } ) ;
55
+
49
56
it ( 'should should not clear previous defined classes' , ( ) => {
50
57
let fixture = TestBed . createComponent ( TestApp ) ;
51
58
let testComponent = fixture . debugElement . componentInstance ;
Original file line number Diff line number Diff line change @@ -18,12 +18,14 @@ import {
18
18
OnDestroy ,
19
19
Optional ,
20
20
Self ,
21
+ ViewChild ,
21
22
ViewEncapsulation ,
22
23
} from '@angular/core' ;
23
24
import {
24
25
CanColor ,
25
26
CanDisable ,
26
27
CanDisableRipple ,
28
+ MatRipple ,
27
29
mixinColor ,
28
30
mixinDisabled ,
29
31
mixinDisableRipple
@@ -135,6 +137,9 @@ export class MatButton extends _MatButtonMixinBase
135
137
/** Whether the button is icon button. */
136
138
_isIconButton : boolean = this . _hasHostAttributes ( 'mat-icon-button' ) ;
137
139
140
+ /** Reference to the MatRipple instance of the button. */
141
+ @ViewChild ( MatRipple ) ripple : MatRipple ;
142
+
138
143
constructor ( elementRef : ElementRef ,
139
144
private _platform : Platform ,
140
145
private _focusMonitor : FocusMonitor ) {
You can’t perform that action at this time.
0 commit comments