我正在使用ionic 2
下面是我的模板代码
<div class="messagesholder" *ngFor="let chat of chatval | orderby:'[date]'; let last = last">
{{last ? callFunction() : ''}}
<div *ngIf="chat.sender == currentuser || chat.receiver == currentuser">
<p *ngIf="msgdate === undefined" class="chat-date" #ChatDate id="ChatDate" >{{chat.date | amDateFormat:'LL'}}</p>
{{checkdate(chat.date)}}
</div>
<div class="message" *ngIf="chat.sender == currentuser || chat.receiver == currentuser" [ngClass]="{'me': currentuser == chat.sender}">
<div class='image' *ngIf="chat.path" >
<img *ngIf="chat.path" [src]="chat.path" imageViewer/><br>
<span *ngIf="chat.path_text">{{chat.path_text}}</span>
<span style="font-size:9px;">{{chat.date | amDateFormat:'hh:mmA'}}</span>
</div>
<div *ngIf="chat.message_text">
<span>{{chat.message_text}}</span>
<span style="font-size:9px;">{{chat.date | amDateFormat:'hh:mmA'}}</span>
</div>
</div>
</div>下面是我的函数
checkdate(i)
{
console.log("date");
console.log(i);
this.msgdate=i;
}我需要相同的日期值不是检查日期我使用此函数{{ repeated.Because (chat.date)}}获取输入元素值。
但是我得到了这个错误。
Error in ./ChatPage class ChatPage - caused by: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.我怎样才能解决这个问题...
敬请指教,
谢谢
发布于 2017-04-12 13:46:41
由于您试图修改在loop语句中执行后端处理的对象,因此出现以下错误。
Error in ./ChatPage class ChatPage - caused by: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.如果你想获得唯一的日期,那么你可以像下面的例子一样,它将从你的集合中给出唯一的chatDate:
let Values = this.chatval.map(function (item) { return item["date"]; }).filter(this.OnlyUnique);
OnlyUnique(value, index, self): any {
return self.indexOf(value) === index;
}https://stackoverflow.com/questions/43361035
复制相似问题