突然代码停止工作,我开始抓住
TypeError: null is not an object (evaluating '_this._inputContainer._elementRef')
当我尝试检查angular's example时,我也收到了这条消息(我删除了md-input-container,但是有时候我没有使用它,而且它正常工作。如果我写md-input-container包装器,一切正常,会发生什么?)
我的代码:
<input
mdInput
id="{{id}}"
placeholder="{{inputPlaceholder}}"
value="{{value}}"
[formControl]="inputControl"
[mdAutocomplete]="auto">
<md-autocomplete #auto="mdAutocomplete">
<md-option *ngFor="let user of users" [value]="user.userName">
<img class="avatar" src="{{user.profilePicture}}">
<span>@{{user.userName}}</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
})
})
}