首页 > 解决方案 > 以角度 4 在网格中显示 json 数组

问题描述

我在显示我从服务获取到 html 的 JSON 数组数据时遇到问题下面是我component.ts从中获取 JSON 数据的文件代码

userdata(){
this.http.get(this.url).subscribe((res)=>{
this.arrBirds = res.json() as Application[];

console.log(this.arrBirds)
});

下面是我想要在网格中显示 JSON 数据的 HTML 代码

<table cellpadding="0" width="100%" cellspacing="0" border="0" class="search_grid_view table-striped">
    <thead>
        <tr>
            <!-- <th style="min-width: 100px;">Login Name</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Role</th>
            <th>Agreement Type</th>
            <th>Status</th>
            <th>User Type</th>
            <th>Email</th> -->
            <!-- <th>Action</th> -->


            <th *ngFor="let col of getColumns">
                {{col}}
            </th>
        </tr>
    </thead>
    <tbody>

        <tr *ngFor="let char of Griddata">
            <td *ngFor="let col of getColumns">
              {{char[col]}
            </td>
            <!-- <td>Demo</td>
            <td>User</td>
            <td>Admin</td>
            <td>ISDA, MRA</td>
            <td><a class="red_green_btn red_button" href="javascript:void(0);">In-Active</a></td>
            <td>eClerx</td>
            <td>demo.user@eclerx.com</td> -->
            <!-- <td><a href="#"><img src="~/Content/images/edit.png" alt="" /> </a></td> -->
        </tr>

    </tbody>
</table>

但是网格没有填充 JSON 数据。上述问题的方法应该是什么?

标签: angular

解决方案


推荐阅读