Angular2-字体选择选项不显示
在我的Angular2-字体选择选项不显示,angular,firebase,typehead,Angular,Firebase,Typehead,在我的component.html <input formControlName="location" [typeahead]="states" typeaheadOptionsLimit="7" typeaheadMinLength="4" placeholder="Please enter your postcode" class="form-control" (keyup)="postcodeChanged()"> 此方法调用连接到Fireb
component.html
<input formControlName="location" [typeahead]="states" typeaheadOptionsLimit="7" typeaheadMinLength="4" placeholder="Please enter your postcode"
class="form-control" (keyup)="postcodeChanged()">
此方法调用连接到Firebase的服务,并检索与提供的邮政编码匹配的位置。当Iconsole.log('states value is',this.states)时
我看到了正确的值,但是由于某种原因,字体
下拉列表(允许最终用户选择他们的地址)没有出现
this.states
声明为公共状态:选项[]=[]代码>位于我的.ts
文件的顶部。我不确定为什么这不会开火?数组已填充,状态
在.html
谁能发现我错过了什么
更新
所以设置
输入字段上的[typeaheadWaitMs]=“800”
似乎起到了作用,但我知道这是一个异步过程,所以如果有人能帮我解决这个问题,使它更干净,而不是延迟调用,那就太好了 您可以直接为状态
对象分配可观察的,比如this.states=this.service.getLocation(enteredPostcode)
是的,我知道,但是这仍然不能解决我当前遇到的问题。
postcodeChanged() {
var enteredPostcode = this.editProfileForm.value['location'];
if (enteredPostcode.length == 4) {
this.states = [];
this.service.getLocation(enteredPostcode).subscribe(response => {
response.forEach(entry => {
this.states.push({
id: entry.Id, description: entry.Description
});
})
console.log('states value is', this.states);
});
}
}