Angular 在“角度材质日历”表中再添加一行
我想在一个有角度的日历的每个表中再添加一行 这是你的电话号码Angular 在“角度材质日历”表中再添加一行,angular,angular-material,Angular,Angular Material,我想在一个有角度的日历的每个表中再添加一行 这是你的电话号码 我知道在jQuery中我们可以使用append功能,但我不确定在使用角度材质日历的情况下如何使用它。在html文件中的标记之后添加 <div *ngFor="let m of months"> <mat-calendar [dateClass]="dateClass()" [startAt]="m" [selected]="selectedDate" (selectedChange)="onSelect($even
我知道在jQuery中我们可以使用append功能,但我不确定在使用角度材质日历的情况下如何使用它。在html文件中的
标记之后添加
<div *ngFor="let m of months">
<mat-calendar [dateClass]="dateClass()" [startAt]="m" [selected]="selectedDate"
(selectedChange)="onSelect($event)"></mat-calendar>
<br>
</div>
您可以使用普通的DOM函数:
@ViewChildren(MatCalendar, {read: ElementRef}) calendars: QueryList<ElementRef>;
ngAfterViewInit() {
this.calendars.forEach(calendarEl => {
const tbody: HTMLElement = calendarEl.nativeElement.querySelector('tbody');
const tr = document.createElement('tr');
for (let i = 0; i < 7; i++) {
tr.appendChild(document.createElement('td'));
}
tbody.appendChild(tr);
})
}
@ViewChildren(MatCalendar,{read:ElementRef})日历:QueryList;
ngAfterViewInit(){
this.calendars.forEach(calendarEl=>{
常量tbody:HTMLElement=calendarEl.nativeElement.querySelector('tbody');
const tr=document.createElement('tr');
for(设i=0;i<7;i++){
tr.appendChild(document.createElement('td'));
}
t附肢儿童(tr);
})
}
如果日历表的最后一行没有7列,您需要添加内容并进行调整。我在表中有行和单元格。我需要再追加一行。这适用于spacingMy bad,我可能有点误解,你能告诉我你指的是哪张桌子吗?我有你的stackblitz例子,我没有看到任何表格。您正在尝试实现动态追加行吗?是的,行日期日历表要更新stackblitz,此代码看起来不错,但在我的本地