Angular 9:在GUI上列出用户的详细信息。

问题描述 投票:0回答:1

我想用angular列出页面上注册的用户。

API响应。

{
  "message": "User list is fetched successfully",
  "result": [
    {
      "firstName": "xcvbn",
      "lastName": "fvbnm",
      "domain": "hgj"
    },
    {
      "firstName": "wdD",
      "lastName": "DWQ",
      "domain": "hDWgj"
    },
    {
      "firstName": "GH",
      "lastName": "J",
      "domain": "RF"
    },
    {
      "firstName": "D",
      "lastName": "F",
      "domain": "K"
    }
  ],
  "status": true,
  "responseCode": "200"
}

我可以得到API-response,但无法在UI上显示列表。这是我为列出用户列表而创建的component.html类。

**component.html**

    <div class="container">
    <div class="container">
    <div class="container">
        <div class="row col-md-6 col-md-offset-2 custyle">
        <table class="table table-striped custab">
        <thead>
            <tr>
                <th>Frist Name</th>
                <th>Last name</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let user of users">
                <td>{{user.firstName}}</td>
                <td>{{user.lastName}}</td>
              </tr>
        </tbody>
        </table>
        </div>
    </div>
angular angular-ui angular9
1个回答
2
投票

试试把你的html改成

<div class="container">
    <div class="container">
    <div class="container">
        <div class="row col-md-6 col-md-offset-2 custyle">
        <table class="table table-striped custab">
        <thead>
            <tr>
                <th>Frist Name</th>
                <th>Last name</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let user of users.result">
                <td>{{user.firstName}}</td>
                <td>{{user.lastName}}</td>
              </tr>
        </tbody>
        </table>
        </div>
    </div>
© www.soinside.com 2019 - 2024. All rights reserved.