[英]How to iterate over array of objects and update time if <mat-checkbox> is checked in angular 9?
我的<mat-table>
中有一组对象,同步属性是<mat-checkbox>
。 我正在尝试这样做,以便在选中一个框然后按下“同步”按钮时,它将使用表中的当前日期和时间更新 lastSynced 属性。
export interface ConnectionData {
name: string;
active: boolean;
connections: string;
location: string;
users: string;
sync: boolean;
lastSynced: Date | null;
}
const CONNECTIONS: ConnectionData[] = [
{name: '', active: false, connections: '', location: '', users: '', sync: false, lastSynced: },
{name: '', active: false, connections: '', location: '', users: '', sync: false, lastSynced: },{name: '', active: false, connections: '', location: '', users: '', sync: false, lastSynced: },
];
拥有在更新表数据的同步按钮(单击)上调用的方法。 就像是:
for( const connection of connectionData ) {
if(connection.sync) {
connection.lastSynced = new Date(); // update to current date
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.