如何将对象放在一个数组之下而不是彼此相邻?

时间:2017-02-23 10:50:24

标签: html css angularjs parse-platform sass

我只需要显示角色内容,使得数组在彼此之下而不是在一条线上彼此相邻,或者我需要在td的那一部分中有一个滚动选项,所以它滚动水平image < / p>

<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其他下。

1 个答案:

答案 0 :(得分:1)

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

&#13;
&#13;
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"] 
    }
  ]
})
&#13;
<!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>
&#13;
&#13;
&#13;