Hey guys I was working on a chat template and I wanted to add a feature to it which loads the last 30 messages of the chat and when you scroll up to the first one, it loads the next 30 messages and so on I tried the scroll function with getting the tag by getting the element by id but it didn't work that will be very kind of you if you offer me an effective solution I also add an event on scroll to HTML file but didn't work scroll spy was also not efficient here is my ts file:
async loadChatMsgs(INum?: number) {
let temp;
if (INum) {
console.log('hiiii');
temp = await this._service.get(this.getUrl, {
uuid: this.myUuid,
type: 'get',
index: INum,
});
} else {
temp = await this._service.get(this.getUrl, {
uuid: this.myUuid,
type: 'get',
});
}
this.message = temp.result.data.messages;
this.avatar = temp.result.data.avatar;
this.userName = temp.result.data.user_name;
this.index = this.message[this.message.length - 1].index;
console.log(this.message);
console.log(this.index);
}