之前,我的Angular 是13
,我的组件工作正常!自那以后,我已经升级到了Angel的其他版本,目前是16
版.我想修复一个warning
,因为我有一个语法问题.
src/app/.../annexes.component.html:6:65 - warning NG8107: The left side of this optional chain
operation does not include 'null' or 'undefined' in its type, therefore the '?.'
operator can be replaced with the '.' operator.
<h2 *ngIf="annexeDetails">{{ annexeDetails?.TITRE }} - {{ id }}</h2>
src/app/.../annexes.component.ts:15:16
templateUrl: './annexes.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AnnexesComponent.
和
Warning: src/app/.../corporate-actions-details-confirm-modal/corporate-actions-details-confirm-modal.component.html:32:60 -
warning NG8107: The left side of this optional chain operation does not include 'null'
or 'undefined' in its type, therefore the '?.' operator can be replaced with the '.' operator.
32 - {{ ostDetail?.LIMITEDATE | date: "d MMMM y" }}.
~~~~~~~~~~
src/app/.../corporate-actions-details-confirm-modal/corporate-actions-details-confirm-modal.component.ts:14:16
14 templateUrl: './corporate-actions-details-confirm-modal.component.html',
我换掉了
<h2 *ngIf="annexeDetails">{{ annexeDetails?.TITRE }} - {{ id }}</h2>
使用
<h2 *ngIf="annexeDetails">{{ annexeDetails.TITRE }} - {{ id }}</h2>
和 the second
{{ ostDetail?.LIMITEDATE | date: "d MMMM y" }}
使用
{{ ostDetail.LIMITEDATE | date: "d MMMM y" }}
但它不适用于这些新的修改,因为ostDetail
可以是null
也可以是undefined
.
我不知道如何解决这个问题.我将不得不返回到版本13
吗?