【发布时间】:2017-06-11 17:52:57
【问题描述】:
我想从 Angular 2 的组件中引用 ng-bootstrap 模态内部的 html 元素
<ng-template #liveView id="liveView" let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Live View</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<canvas #liveViewCanvas style="border: 1px solid black;" width="270" height="480"></canvas>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-xs" (click)="closeLiveViewModal()">
<span class="fa fa-trash"></span> Close
</button>
</div>
</ng-template>
如何在 Angular 2 组件中引用 #liveViewCanvas?通过@viewchild 引用时,我收到“ERROR TypeError: Cannot read property 'nativeElement' of undefined”
【问题讨论】:
-
你查到这件事的真相了吗?我也遇到了同样的问题
标签: angular