@@ -24,7 +24,7 @@ describe('MdAutocomplete', () => {
2424 imports : [
2525 MdAutocompleteModule . forRoot ( ) , MdInputModule . forRoot ( ) , ReactiveFormsModule
2626 ] ,
27- declarations : [ SimpleAutocomplete ] ,
27+ declarations : [ SimpleAutocomplete , AutocompleteWithoutForms ] ,
2828 providers : [
2929 { provide : OverlayContainer , useFactory : ( ) => {
3030 overlayContainerElement = document . createElement ( 'div' ) ;
@@ -790,6 +790,25 @@ describe('MdAutocomplete', () => {
790790
791791 } ) ;
792792
793+ describe ( 'misc' , ( ) => {
794+
795+ it ( 'should allow basic use without any forms directives' , ( ) => {
796+ expect ( ( ) => {
797+ const fixture = TestBed . createComponent ( AutocompleteWithoutForms ) ;
798+ fixture . detectChanges ( ) ;
799+
800+ const input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
801+ input . value = 'd' ;
802+ dispatchEvent ( 'input' , input ) ;
803+ fixture . detectChanges ( ) ;
804+
805+ const options =
806+ overlayContainerElement . querySelectorAll ( 'md-option' ) as NodeListOf < HTMLElement > ;
807+ expect ( options . length ) . toBe ( 1 ) ;
808+ } ) . not . toThrowError ( ) ;
809+ } ) ;
810+
811+ } ) ;
793812} ) ;
794813
795814@Component ( {
@@ -849,6 +868,33 @@ class SimpleAutocomplete implements OnDestroy {
849868}
850869
851870
871+ @Component ( {
872+ template : `
873+ <md-input-container>
874+ <input mdInput placeholder="State" [mdAutocomplete]="auto"
875+ (input)="onInput($event.target?.value)">
876+ </md-input-container>
877+
878+ <md-autocomplete #auto="mdAutocomplete">
879+ <md-option *ngFor="let state of filteredStates" [value]="state">
880+ <span> {{ state }} </span>
881+ </md-option>
882+ </md-autocomplete>
883+ `
884+ } )
885+ class AutocompleteWithoutForms {
886+ filteredStates : any [ ] ;
887+ states = [ 'Alabama' , 'California' , 'Florida' ] ;
888+
889+ constructor ( ) {
890+ this . filteredStates = this . states . slice ( ) ;
891+ }
892+
893+ onInput ( value : any ) {
894+ this . filteredStates = this . states . filter ( s => new RegExp ( value , 'gi' ) . test ( s ) ) ;
895+ }
896+
897+ }
852898
853899/**
854900 * TODO: Move this to core testing utility until Angular has event faking
0 commit comments