如何解决对象可能为“空” InputText(filterGlobal) Primeeng
嗨,我正在用primeng 实现一个产品的crud 表,但我发现一个错误:对象可能是'null' 引用了一个事件, 我该如何解决这个错误?
<p-table #dt [value]="products" [rows]="10" [paginator]="true" [globalFilterFields]="['product.nome']"
[(selection)]="selectedProducts" [rowHover]="true" dataKey="id"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [showCurrentPageReport]="true">
<ng-template pTemplate="caption">
<div class="p-d-flex p-ai-center p-jc-between">
<h5 class="p-m-0">Manage Products</h5>
<span class="p-input-icon-left">
<i class="pi pi-search"></i>
<input pInputText type="text" (input)="dt.filterGlobal($event.target.value,'contains')" placeholder="Search..." /> <!--error here-->
</span>
</div>
</ng-template>
这里是错误
src/app/components/product/product.component.html:26:90 - error TS2531: Object is possibly 'null'.
26 <input pInputText type="text" (input)="dt.filterGlobal($event.target.value,'contains')" placeholder="Search..." />//value is null
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。