Firebase与离子滚动问题

时间:2019-07-17 20:53:56

标签: angular ionic-framework

当视图成为负载时,我试图滚动到底部,我尝试了几种方法,但没有任何一项工作。有时他会停在屏幕中间,我认为是因为未加载所有消息(30)。

HTML代码:

<ion-list>
  <ion-item *ngFor="let msg of messages; let last : last;">
        {{msg.message}}
        {{callLastItem(last)}}
  </ion-item>
</ion-list>

TS

callLastItem(last){
if(last){
    this.content.scrollToBottom(1000);
}
}
// i try set timeout too
ionViewDidLoad(){
setTimeout(()=>{
this.content.scrollToBottom(1000);
}, 1000)
}

1 个答案:

答案 0 :(得分:0)

我以这种形式解决了它: 这是在构造函数中

this.fireservice.getLiveConversation()
.subscribe((conversacion: any) => 
{
    this.conversacion = conversacion;
     this.content.scrollToBottom();
});