我正在使用 Angular Calendar https://github.com/mattlewis92/angular-calendar,我希望每个单元格有一个以上的徽章,每个徽章都放在一个计数器中,用于不同类型的事件。有不同类型的事件(使用事件中的元属性)。我在使用用于一天事件的计数器时遇到了困难。
这是我想要的结果。
编辑:这是我尝试过的
我使用日历单元的这个自定义模板来添加徽章。
<ng-template #customCellTemplate let-day="day" let-locale="locale">
<div class="cal-cell-top">
<span style="background-color: grey" class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ day.badgeTotal }}</span>
<span class="cal-day-number">{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span>
</div>
<div>
<span class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{countErrors()}}</span>
<span style="background-color: green" class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ countSuccesses() }}</span>
<span style="background-color: orange" class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ countWarnings() }}</span>
</div>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
这三种功能countErrors() countWarnings()和countSuccesses()计算相同的类型(错误或成功或警告)的事件的数量。
事件类型由meta属性指定:
{
start: subDays(startOfDay(new Date()), 1),
end: addDays(new Date(), 1),
title: 'A 3 day event', …Run Code Online (Sandbox Code Playgroud) 我在 NestJS 中使用类验证器来创建这样的验证:
export class LoginDTO {
@IsEmail()
@MinLength(4)
email: string;
@IsNotEmpty()
@MinLength(4)
password: string;
Run Code Online (Sandbox Code Playgroud)
}
它有效,但不像预期的那样。返回的对象如下所示:
{
"statusCode": 400,
"message": [
"email must be longer than or equal to 4 characters",
"email must be an email"
],
"error": "Bad Request"
Run Code Online (Sandbox Code Playgroud)
}
虽然我希望它包含这样的所有信息:
{
"statusCode": 400,
[{
target: /* post object */,
property: "title",
value: "Hello",
constraints: {
length: "$property must be longer than or equal to 10 characters"
}]
"error": "Bad Request"
}
Run Code Online (Sandbox Code Playgroud)
如何返回所有丢失的属性?