刷新时丢失arraylist内容

时间:2019-03-25 11:53:46

标签: angular typescript refresh

我有一个组件,可以在聊天应用程序上呈现朋友列表,就像whatsapp Web应用程序的左侧部分一样。一旦调用OnInit方法,它就可以填充component.ts的数组,但是如果刷新页面,则该数组为空,然后好友列表也为空。有没有一种方法可以调用方法getFriendList来填充数组?据我了解,onInit仅被调用一次,但是刷新页面时也不应调用它吗?

dummyusers;
constructor(private rdf: RdfService) {
    this.getUserList();
}

ngOnInit() {
    this.getUserList();
}

async getUserList() {
    this.dummyusers = [];
await this.rdf.getFriends(this.dummyusers);

}

0 个答案:

没有答案
相关问题