我怎样才能清除我的 Angular 2 ng-if textarea 的值,这样它就不会通过

How can I clear the value of my Angular 2 ng-if textarea so that it's not passed

现在我有两个文本区域,它们通过 *ngIf 指令有条件地出现,基于用户 selection 在之前的 select 框中输入。它工作得很好,除了如果他们返回并更改 select 框的值,文本区域会相应地切换,但文本区域的先前值不会被删除,它只是隐藏在视图之外。

我尝试添加一个在我的组件绑定到 onchange 事件中定义的函数,以将视图中隐藏的文本框的值重置为空字符串,但无济于事。数据还在持续

<ss-multiselect-dropdown  (onchange)=" resetdcn()"   id="substatus" 
*ngIf="ddlCorrespondenceStatus == 'M'" class="report-multiselect"
                                 [options]="ddlCorrespondenceSubStatuses"                                     
[settings]="genericSearchMSDropdownSettings"
                                 [texts]="statusMSDropdownTextSettings"                                    
[(ngModel)]="selectedCorrespondenceSubStatuses"                                   
 (ngModelChange)="handleStatusSelection($event)">
        </ss-multiselect-dropdown>


        <ss-multiselect-dropdown  (onchange)=" resetdcn()"  
     *ngIf="ddlCorrespondenceStatus == 'G'" class="report-multiselect"
                                 [options]="ddlStatus"                                     
    [settings]="genericSearchMSDropdownSettings"
                                 [texts]="statusMSDropdownTextSettings"
                                 [(ngModel)]="selectedStatuses"                                     
    (ngModelChange)="handleStatusSelection($event)">
        </ss-multiselect-dropdown>
          </div>
        </td>
        <td>

      <textarea (ngModelChange)="handleCorrespondenceDcnSelection($event)"  
    *ngIf="ddlCorrespondenceStatus == 'M'" id="txtDcn"name="txtDcn" 
    type="text" 
    placeholder="Correspondondence DCN " class="form-control input-md" 
    [(ngModel)]="txtCorrespondenceDcn"></textarea>


      <textarea (ngModelChange)="handleClaimDcnSelection($event)" 
    *ngIf="ddlCorrespondenceStatus == 'G'" id="txtDcn"  name="txtDcn" 
    type="text" placeholder="Claim DCN " class="form-control input-md" 
    [(ngModel)]="txtDcn"></textarea>

resetdcn() 中,只需将文本区域模型值设置为 null。它们是数据绑定的,因此除此之外您无需执行任何特殊操作。

public resetdcn(){
   // ...

   this.txtCorrespondenceDcn = null;
   this.txtDcn = null;
}

问题是函数没有被正确调用,而不是函数本身。它需要是 (ngModelChange) ="resetdcn()"