我只需要显示角色内容,使得数组在彼此之下而不是在一条线上彼此相邻,或者我需要在td的那一部分中有一个滚动选项,所以它滚动水平 < / 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其他下。
答案 0 :(得分:1)
在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"]
}
]
})
&#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;