@@ -16,7 +16,13 @@ describe('MdSelect', () => {
16
16
beforeEach ( async ( ( ) => {
17
17
TestBed . configureTestingModule ( {
18
18
imports : [ MdSelectModule . forRoot ( ) , ReactiveFormsModule , FormsModule ] ,
19
- declarations : [ BasicSelect , NgModelSelect , ManySelects , NgIfSelect ] ,
19
+ declarations : [
20
+ BasicSelect ,
21
+ NgModelSelect ,
22
+ ManySelects ,
23
+ NgIfSelect ,
24
+ FloatingPlaceholderSelect
25
+ ] ,
20
26
providers : [
21
27
{ provide : OverlayContainer , useFactory : ( ) => {
22
28
overlayContainerElement = document . createElement ( 'div' ) as HTMLElement ;
@@ -1139,6 +1145,20 @@ describe('MdSelect', () => {
1139
1145
} ) ;
1140
1146
} ) ) ;
1141
1147
1148
+ it ( 'should be able to disable the floating placeholder' , ( ) => {
1149
+ let fixture = TestBed . createComponent ( FloatingPlaceholderSelect ) ;
1150
+ let placeholder = fixture . debugElement . query ( By . css ( '.md-select-placeholder' ) ) . nativeElement ;
1151
+
1152
+ fixture . detectChanges ( ) ;
1153
+
1154
+ expect ( placeholder . style . visibility ) . toBe ( 'visible' ) ;
1155
+
1156
+ fixture . componentInstance . control . setValue ( 'pizza-1' ) ;
1157
+ fixture . detectChanges ( ) ;
1158
+
1159
+ expect ( placeholder . style . visibility ) . toBe ( 'hidden' ) ;
1160
+ } ) ;
1161
+
1142
1162
} ) ;
1143
1163
1144
1164
} ) ;
@@ -1235,6 +1255,29 @@ class NgIfSelect {
1235
1255
@ViewChild ( MdSelect ) select : MdSelect ;
1236
1256
}
1237
1257
1258
+ @Component ( {
1259
+ selector : 'floating-placeholder-select' ,
1260
+ template : `
1261
+ <md-select placeholder="Food I want to eat right now" [formControl]="control"
1262
+ [floatingPlaceholder]="floatingPlaceholder">
1263
+ <md-option *ngFor="let food of foods" [value]="food.value">
1264
+ {{ food.viewValue }}
1265
+ </md-option>
1266
+ </md-select>
1267
+ ` ,
1268
+
1269
+ } )
1270
+ class FloatingPlaceholderSelect {
1271
+ floatingPlaceholder : boolean = false ;
1272
+ foods : any [ ] = [
1273
+ { value : 'steak-0' , viewValue : 'Steak' } ,
1274
+ { value : 'pizza-1' , viewValue : 'Pizza' } ,
1275
+ { value : 'tacos-2' , viewValue : 'Tacos' }
1276
+ ] ;
1277
+ control = new FormControl ( ) ;
1278
+
1279
+ @ViewChild ( MdSelect ) select : MdSelect ;
1280
+ }
1238
1281
1239
1282
1240
1283
/**
0 commit comments