Angular 如何从typescript文件中隐藏mat复选框

Angular 如何从typescript文件中隐藏mat复选框,angular,typescript,angular-material,Angular,Typescript,Angular Material,我需要根据应用程序中更改的选项卡选择,从typescript文件中隐藏mat复选框控件 这是html文件代码 <mat-checkbox (change)="OnChangeRed($event)" id="check1" class="example-margin" [checked]="matCheckboxRed"></mat-checkbox> 当我的标签更改呼叫时,我需要隐藏复选

我需要根据应用程序中更改的选项卡选择,从
typescript
文件中隐藏
mat复选框
控件

这是
html
文件代码

<mat-checkbox (change)="OnChangeRed($event)" id="check1" class="example-margin" [checked]="matCheckboxRed"></mat-checkbox> 
当我的标签更改呼叫时,我需要隐藏复选框

tabChanged(index)
{

}

我如何做到这一点

您可以使用带有复选框的ngModel,如下所示:

<mat-checkbox *ngIf="show" (change)="OnChangeRed($event)" id="check1" class="example-margin" [checked]="matCheckboxRed"></mat-checkbox> 
使用ViewChild的另一种方法:

<mat-checkbox #checkbox (change)="OnChangeRed($event)" id="check1" class="example-margin" [checked]="matCheckboxRed"></mat-checkbox> 

请将您的标签共享为well@YogendraR-请检查我的最新问题。
show: boolean = true;

tabChanged(index)
{
   if(index == "your tab index"){
     this.show = false;
   }

}
<mat-checkbox #checkbox (change)="OnChangeRed($event)" id="check1" class="example-margin" [checked]="matCheckboxRed"></mat-checkbox> 
@ViewChild('checkbox') el:ElementRef;

    tabChanged(index)
    {
       if(index == "your tab index"){
     this.el.nativeElement.style.display='none';
       }
    }