mardi 23 mai 2017

Why md-autocomplete / mdInput throws type error

Suddenly code stop working, and Im starting to catch throw

TypeError: null is not an object (evaluating '_this._inputContainer._elementRef')

This message I get too, when I try to check angular's example (I'm removing md-input-container, but all time, I didn't use it, and it worked normally. If I write md-input-container wrapper, all works correct, what happens?)

My code:

<input 
     mdInput 
     id=""
     placeholder="" 
     value=""
    [formControl]="inputControl"
    [mdAutocomplete]="auto">

<md-autocomplete #auto="mdAutocomplete">
    <md-option *ngFor="let user of users" [value]="user.userName">
      <img class="avatar" src="">
      <span>@</span>
    </md-option>
</md-autocomplete>

constructor(private userInfoRepository: UserInfoRepository) {
   this.inputControl = new FormControl();
   this.inputControl
    .valueChanges
    .subscribe(value => {
      this
        .userInfoRepository
        .findUsers(value)
        .subscribe(usersResult => {
           this.users = usersResult
        })
    })
}




Aucun commentaire:

Enregistrer un commentaire