小编Vet*_*eto的帖子

获取ng-template中的元素参考

这是我的模板:

<ng-template #template>
    <input #newimg  type="file" class="col-md-10" (change)="fileChange($event)"/>
</ng-template>
Run Code Online (Sandbox Code Playgroud)

我不能得到引用#newimg时,其内部的ng-template(如果我改变它工作正常ng-templatediv!)

@ViewChild('newimg') img: ElementRef; //doesnt work
Run Code Online (Sandbox Code Playgroud)

我需要在上传图像后将其值设置为空,但始终未定义.

ngx-bootstrap angular ngx-bootstrap-modal angular5

6
推荐指数
1
解决办法
4174
查看次数