我只需要显示角色内容,以便在彼此下而不是在一行上彼此相邻排列数组,或者我需要在td的该部分中具有滚动选项,以便它水平滚动html - 如何将对象放置在彼此下方而不是彼此相邻的数组中?-LMLPHP

<tr ng-repeat="companyUser in companyUsers | filter:search | orderBy:sort">
    <td>
        <nobr>{{companyUser.user.firstName}}</nobr>
    </td>
    <td>
        <nobr>{{companyUser.user.lastName}}</nobr>
    </td>
    <td>
        <nobr>{{companyUser.user.username}}</nobr>
    </td>
    <td>
        <nobr>{{companyUser.user.role}}</nobr>
    </td> </tr>


我使用Parse用Parse和Parse数据库加载数据,但是主要的事情是我希望td角色可以水平滚动或在其他eac下。

最佳答案

在您的ng-repeat标记中的人的角色上添加<td>



angular.module('app', [])
.controller('ctrl', function($scope) {
  $scope.data = [
    {
      firstname: "User",
      lastname: "Lastname",
      email: "email@email.com",
      role: ["Role1", "Role2", "Role3", "Role4"]
    },
    {
      firstname: "User2",
      lastname: "Lastname2",
      email: "email2@email2.com",
      role: ["Role1", "Role2", "Role3", "Role4"]
    }
  ]
})

<!DOCTYPE html>
<html>

  <head>
    <script data-require="angular.js@1.6.0" data-semver="1.6.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-app="app" ng-controller="ctrl">
    <table>
      <tr>
        <th>First name</th>
        <th>Last name</th>
        <th>Email</th>
        <th>Roles</th>
      </tr>
      <tr ng-repeat="person in data">
        <td>{{person.firstname}}</td>
        <td>{{person.lastname}}</td>
        <td>{{person.email}}</td>
        <td><div ng-repeat="role in person.role">{{role}}</div></td>
      </tr>
    </table>
  </body>
</html>

10-05 20:52
查看更多