在我的代码下面:
modal-checkout.component.html
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">Profile update</h4>
...
modal-checkout.component.ts
@ViewChild('content') contentRef: TemplateRef<> ??????
问题:如何在modal-checkout.component.ts中引用#content?
答案 0 :(得分:0)
您可以通过ViewChild()之后的名称进行调用:
@ViewChild('content') contentRef;
// call in a function or onInit()
testFunction() {
// The call looks like this
this.contentRef.DO_SOMETHING_HERE
// Log out content to see what it looks like
console.log('content', this.contentRef);
}