Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我怎样才能在Angularfire 2中等待可观察到的?_Angular_Firebase_Observable_Angularfire2 - Fatal编程技术网

我怎样才能在Angularfire 2中等待可观察到的?

我怎样才能在Angularfire 2中等待可观察到的?,angular,firebase,observable,angularfire2,Angular,Firebase,Observable,Angularfire2,问题是chat.name最初显示为空白,因为映射尚未完成。有没有办法在映射更新数据之前等待它 this.chats = this.af.database.list('/chats/' + this.mainService.getUserId(), { query: { orderByChild: 'timestamp' } }).map((chats) => { return chats.map( chat => { chat.name = t

问题是chat.name最初显示为空白,因为映射尚未完成。有没有办法在映射更新数据之前等待它

this.chats = this.af.database.list('/chats/' + this.mainService.getUserId(), {
  query: {
    orderByChild: 'timestamp'
  }
}).map((chats) => {
    return chats.map( chat => {
        chat.name = this.af.database.object(`/users/${chat.uid}`);
        return chat;
    })
});
这是用户界面

<ul>
    <li *ngFor="let chat of chats | async">
       {{ (chat.name | async)?.name }} : {{  chat.lastMessage }}
    </li>
</ul>
    {{(chat.name | async)?.name}:{{{chat.lastMessage}}
请参见此答案-

但我怀疑您需要将elvis操作符添加到HTML页面


{{chat?.name}

事实上,我刚才已经看过了。但我可以显示值。只是,一旦我推送一条消息,它将保持空白几秒钟,然后显示chat.name。我没有要查看的UI代码,所以这里很难提供任何指导?我刚刚编辑了我的帖子。很抱歉。问题是,首先它会显示最后一条消息,几秒钟后它会显示chat.name。非常感谢。如果我试着把它包装成一个div,然后做一个*ngIf,当有新的更新时,它会让用户感到恼火。非常感谢。