这是代码:
<nz-table #listTable nzSize="middle" [nzData]="data">
<thead>
<tr>
<th nzShowExpand></th>
<th>Location</th>
<th>Device</th>
<th class="tbWidth text-center">Actions</th>
</tr>
</thead>
<tbody>
<ng-template ngFor let-data [ngForOf]="listTable.data">
<tr>
<td nzShowExpand [(nzExpand)]="mapOfExpandData[data.id]"></td>
<td nzBreakWord [textContent]="data.name"></td>
<td nzBreakWord [textContent]="data.device"></td>
<td nzBreakWord class="text-center">
<nz-button-group>
<button nz-button nzType="primary" (click)="openFormDrawer(data)"><i nz-icon nzType="edit"
nzTheme="outline"></i></button>
<button nz-button nzType="danger" (click)="deleteRoomData(data)"><i nz-icon nzType="delete"
nzTheme="outline"></i></button>
</nz-button-group>
</td>
</tr>
<tr [nzExpand]="mapOfExpandData[data.id]">
<td></td>
<td colspan=7>
<nz-table>
<thead>
<tr>
<th nzWidth="25%">Location Code</th>
<th nzWidth="25%">Location Description</th>
<th nzWidth="25%">Device Code</th>
<th nzWidth="25%">Device Description</th>
</tr>
</thead>
<tbody>
<tr>
<td nzBreakWord [textContent]="data.locationCode"></td>
<td …Run Code Online (Sandbox Code Playgroud) limitExceed(params: any) {
params.forEach((data: any) => {
if (data.humidity === 100) {
this.createNotification('warning', data.sensor, false);
} else if (data.humidity >= 67 && data.humidity <= 99.99) {
this.createNotification('warning', data.sensor, true);
}
});
}
createNotification(type: string, title: string, types: boolean): void {
this.notification.config({
nzPlacement: 'bottomRight',
nzDuration: 5000,
});
if (types) {
this.notification.create(
type,
title,
'Humidity reached the minimum limit'
);
} else {
this.notification.create(
type,
title,
'Humidity reached the maximum'
);
}
}
Run Code Online (Sandbox Code Playgroud)
如何让它每 5 分钟触发/警报一次。但首先它会发出警报,然后在第一次警报/触发之后,它会每 5 分钟再次发出警报/触发。
因为我已经这样设置了setInterval。
setInterval(() …Run Code Online (Sandbox Code Playgroud) 这是代码:
data = [
{
'id': 'asdja',
'username': 'james',
},
{
'id': 'asqweja',
'username': 'rhou',
},
{
'id': 'asdqweqj',
'username': 'arianne'
},
{
'id': 'qpoaksl',
'username': 'ryan'
}
];
Run Code Online (Sandbox Code Playgroud)
我正在尝试检查是否username已经存在。
例如,如果我输入,"james"那么它应该显示"Username already exists"
我尝试使用查找:
if (username === data.find((x: any) => x.username === x.username) {
console.log('Username already exists');
} else {
console.log('');
}
Run Code Online (Sandbox Code Playgroud)