[英]how to access ng-template attribute with jquery
我正在使用帶有自定義模板的 angular-calendar,如下所示: https : //mattlewis92.github.io/angular-calendar/#/custom-templates
我的 html 中有 ng-template 元素
<ng-template #customCellTemplate let-day="day" let-viewDate="event"let-locale="locale" [let-status]="statuses">
並在我的 mwl-calendar-month-view 元素中調用 customCellTemplate
<mwl-calendar-month-view [viewDate]="viewDate" [events]="events" (eventClicked)="handleEvent('Clicked', $event.event)"
[cellTemplate]="customCellTemplate">
</mwl-calendar-month-view>
現在我想在我的 component.ts 文件中訪問 day(在 ng-template 中 - let-day="day")
我想我可以用 jquery 做到這一點,但不知道怎么做,如果有另一種方法,請告訴我
謝謝!!
您可以使用 ViewChild 指令來訪問該元素。 然后您可以登錄它以查看所有可用信息。
export class AppComponent implements AfterViewInit {
@ViewChild('customCellTemplate') customCellTemplate : TemplateRef;
ngAfterViewInit() {
console.log(customCellTemplate);
}
}
我認為這種方式可以讓您訪問這些參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.