Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 添加行值的条件(角度材质)_Html_Angular_Typescript_Angular Material_Mat Table - Fatal编程技术网

Html 添加行值的条件(角度材质)

Html 添加行值的条件(角度材质),html,angular,typescript,angular-material,mat-table,Html,Angular,Typescript,Angular Material,Mat Table,我想对当前列的值添加一个条件。我无法读取当前行的值。 我不知道我必须使用什么变量来检查我在行中使用的条件,但没有定义 <ng-container matColumnDef="idCve"> <th mat-header-cell matHeaderCellDef mat-sort-header> IDCVE </th> <ng-container ngIf="row.idCve != null; else dothis" >

我想对当前列的值添加一个条件。我无法读取当前行的值。 我不知道我必须使用什么变量来检查我在行中使用的条件,但没有定义

<ng-container matColumnDef="idCve">
    <th mat-header-cell matHeaderCellDef mat-sort-header> IDCVE </th>
    <ng-container ngIf="row.idCve != null; else dothis" >
        <td mat-cell matCellDef="let row"> {{row.idCve}} </td>
    </ng-container>
    <ng-template #dothid>
        <td mat-cell matCellDef="let row"> --------- </td>
    </ng-template>
</ng-container>
也许像这样?:)

HTML


vulnerabilityServiceService.getVulnerabilities()从何处获取漏洞?嗨,achraf,你是否发现模板的字母ID错误<代码>,这是示例还是真实代码?
Constructor(vulnerabilityServiceService: VulnerabilityServiceService) {
    const vulnerabilities = vulnerabilityServiceService.getVulnerabilities();
    // Assign the data to the data source for the table to render
    this.dataSource = new MatTableDataSource(vulnerabilities);
}
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="position">
    <th mat-header-cell *matHeaderCellDef> No. </th>
    <td mat-cell *matCellDef="let element">
        <div *ngIf="element != 0; else elseDiv">
            {{element}}
        </div>
        <ng-template #elseDiv>
            ----------------
        </ng-template>
    </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
  displayedColumns: string[] = ['position'];
  dataSource = [1, 0, 2, 0, 3, 0];