Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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
Angular 设置材质表中数组属性中的值_Angular_Angular Material - Fatal编程技术网

Angular 设置材质表中数组属性中的值

Angular 设置材质表中数组属性中的值,angular,angular-material,Angular,Angular Material,我正在创建一个材质表。数据源的元素具有数组属性。我想在表中的每一列中显示该属性中成员的值,如下面的代码所示。但是,没有显示任何内容。我哪里弄错的 注意:我用来创建多列的ngFor-in-ng容器 {{vendor.Name} {{成本} {{textValue}} 尝试使用th和td元素,如下所示: <ng-container *ngFor="let vendor of vendors" [matColumnDef]="vendor.Name"> <th mat-he

我正在创建一个材质表。数据源的元素具有数组属性。我想在表中的每一列中显示该属性中成员的值,如下面的代码所示。但是,没有显示任何内容。我哪里弄错的

注意:我用来创建多列的ngFor-in-ng容器


{{vendor.Name}
{{成本}
{{textValue}}

尝试使用
th
td
元素,如下所示:

<ng-container *ngFor="let vendor of vendors" [matColumnDef]="vendor.Name">
    <th mat-header-cell *matHeaderCellDef>{{vendor.Name}}</th>
    <td mat-cell *matCellDef="let element">
        <span *ngIf="element.Type == 2 else textValue">
            <span *ngFor="let cost of element.Cost">
                {{cost}}
            </span>
        </span>
        <ng-template #textValue>
            <span *ngFor="let textValue of element.TextValue">
                {{textValue}}
            </span>
        </ng-template>
    </td>
</ng-container>

{{vendor.Name}
{{成本}
{{textValue}}

尝试使用
th
td
元素,如下所示:

<ng-container *ngFor="let vendor of vendors" [matColumnDef]="vendor.Name">
    <th mat-header-cell *matHeaderCellDef>{{vendor.Name}}</th>
    <td mat-cell *matCellDef="let element">
        <span *ngIf="element.Type == 2 else textValue">
            <span *ngFor="let cost of element.Cost">
                {{cost}}
            </span>
        </span>
        <ng-template #textValue>
            <span *ngFor="let textValue of element.TextValue">
                {{textValue}}
            </span>
        </ng-template>
    </td>
</ng-container>

{{vendor.Name}
{{成本}
{{textValue}}

你能在问题中添加供应商的json吗?你能在问题中添加供应商的json吗?好的,让我试试好的,让我试试