0

我有一个对象数组,它们在我<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: },

];
4

1 回答 1

0

拥有在更新表数据的同步按钮(单击)上调用的方法。就像是:

for( const connection of connectionData ) {
    if(connection.sync) {
       connection.lastSynced = new Date(); // update to current date
    }
}
于 2020-07-24T16:38:29.497 回答