I am using ionic 2
Here is my code....
<div class="messagesholder"
*ngFor="let chat of chatval | orderby:'[date]'; let i = index;let first=first;let last = last;">
{{last ? callFunction() : ''}}
<div *ngIf="chat.sender == currentuser || chat.receiver == currentuser" >
{{checkdate(chat.date)}}
<p class="chat-date" id="abc" #abc>{{msgdate | amDateFormat:'LL'}}</p>
</div>
Here is my checkdate function
checkdate(date)
{
var res = date.split(" ");
var A=res[0];
var local=localStorage.getItem('chatdate');
this.msgdate="";
if(local === undefined || local === null)
{
this.msgdate=A;
localStorage.setItem('chatdate',this.msgdate);
}
else if(local !== undefined)
{
console.log(local != A);
if(local != A)
{
this.msgdate = A;
localStorage.setItem('chatdate',this.msgdate);
}
}
}
callFunction(){
this.content.scrollToBottom(0)
}
It's work.But I getting this error.
FIREBASE WARNING: Exception was thrown by user callback. Error: Expression has changed after it was checked. Previous value: 'April 10, 2017'. Current value: ''.
Because I go this working by having these lines in my code :
constructor(private cdRef: ChangeDetectorRef) {}
ngAfterViewChecked() {
//explicit change detection to avoid "expression-has-changed-after-it-was-checked-error"
this.cdRef.detectChanges();
}
But Now I am getting this error
database.js:62 FIREBASE WARNING: Exception was thrown by user callback. RangeError: Maximum call stack size exceeded