@@ -41,7 +41,6 @@ import {MdOptionSelectionChange, MdOption} from '../core/option/option';
41
41
import { ENTER , UP_ARROW , DOWN_ARROW , ESCAPE } from '../core/keyboard/keycodes' ;
42
42
import { Directionality } from '../core/bidi/index' ;
43
43
import { MdFormField } from '../form-field/index' ;
44
- import { MdInput } from '../input/input' ;
45
44
import { Subscription } from 'rxjs/Subscription' ;
46
45
import { merge } from 'rxjs/observable/merge' ;
47
46
import { fromEvent } from 'rxjs/observable/fromEvent' ;
@@ -154,7 +153,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
154
153
private _changeDetectorRef : ChangeDetectorRef ,
155
154
@Inject ( MD_AUTOCOMPLETE_SCROLL_STRATEGY ) private _scrollStrategy ,
156
155
@Optional ( ) private _dir : Directionality ,
157
- @Optional ( ) @Host ( ) private _inputContainer : MdFormField ,
156
+ @Optional ( ) @Host ( ) private _formField : MdFormField ,
158
157
@Optional ( ) @Inject ( DOCUMENT ) private _document : any ) { }
159
158
160
159
ngOnDestroy ( ) {
@@ -247,8 +246,8 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
247
246
fromEvent ( this . _document , 'touchend' )
248
247
) ) . call ( filter , ( event : MouseEvent | TouchEvent ) => {
249
248
const clickTarget = event . target as HTMLElement ;
250
- const inputContainer = this . _inputContainer ?
251
- this . _inputContainer . _elementRef . nativeElement : null ;
249
+ const inputContainer = this . _formField ?
250
+ this . _formField . _elementRef . nativeElement : null ;
252
251
253
252
return this . _panelOpen &&
254
253
clickTarget !== this . _element . nativeElement &&
@@ -330,16 +329,16 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
330
329
* This method manually floats the placeholder until the panel can be closed.
331
330
*/
332
331
private _floatPlaceholder ( ) : void {
333
- if ( this . _inputContainer && this . _inputContainer . floatPlaceholder === 'auto' ) {
334
- this . _inputContainer . floatPlaceholder = 'always' ;
332
+ if ( this . _formField && this . _formField . floatPlaceholder === 'auto' ) {
333
+ this . _formField . floatPlaceholder = 'always' ;
335
334
this . _manuallyFloatingPlaceholder = true ;
336
335
}
337
336
}
338
337
339
338
/** If the placeholder has been manually elevated, return it to its normal state. */
340
339
private _resetPlaceholder ( ) : void {
341
340
if ( this . _manuallyFloatingPlaceholder ) {
342
- this . _inputContainer . floatPlaceholder = 'auto' ;
341
+ this . _formField . floatPlaceholder = 'auto' ;
343
342
this . _manuallyFloatingPlaceholder = false ;
344
343
}
345
344
}
@@ -409,11 +408,10 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
409
408
// The display value can also be the number zero and shouldn't fall back to an empty string.
410
409
const inputValue = toDisplay != null ? toDisplay : '' ;
411
410
412
- // If it's used in a Material container, we should set it through
413
- // the property so it can go through the change detection.
414
- if ( this . _inputContainer &&
415
- this . _inputContainer . _control instanceof MdInput ) {
416
- this . _inputContainer . _control . value = inputValue ;
411
+ // If it's used within a `MdFormField`, we should set it through the property so it can go
412
+ // through change detection.
413
+ if ( this . _formField ) {
414
+ this . _formField . _control . value = inputValue ;
417
415
} else {
418
416
this . _element . nativeElement . value = inputValue ;
419
417
}
@@ -471,7 +469,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
471
469
}
472
470
473
471
private _getConnectedElement ( ) : ElementRef {
474
- return this . _inputContainer ? this . _inputContainer . _connectionContainerRef : this . _element ;
472
+ return this . _formField ? this . _formField . _connectionContainerRef : this . _element ;
475
473
}
476
474
477
475
/** Returns the width of the input element, so the panel width can match it. */
0 commit comments